Title: eDatagrid - Pass dynamic parameters & query data base on the parameters Post by: Franky on January 26, 2021, 08:07:32 PM Hi Sir,
I'm using editable datagrid extension, having a datagrid which data come from database. However I need to pass parameter(let say userID) to the page so that the datagrid will show different set of data based on login id. May I know any example to achieve this? front end code: dg.edatagrid({ //title:'DataGrid - DetailView', width:'auto', height:'auto', remoteSort:false, //singleSelect:true, nowrap:false, fitColumns:true, striped:true, pagination:true, multiSort:true, url:'php/get_coo_data.php', columns:[[ {field:'item',title:'Item',width:40,sortable:true}, {field:'desc1',title:'Desciption',width:100,sortable:true}, {field:'prod_type',title:'Product Type',width:60,align:'center',sortable:true} ]] }) backend code: require_once('config.php'); userID = POST['userID']; $sql = "SELECT * FROM item WHERE user_id = userID "; $result = mysqli_query($sql); $data = array(); while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } echo json_encode($data); Thanks. Title: Re: eDatagrid - Pass dynamic parameters & query data base on the parameters Post by: jarry on January 26, 2021, 09:58:53 PM When the 'userID' is changed, call the 'load' method with the new parameter values to retrieve data from server.
Code: dg.edatagrid('load',{ Title: Re: eDatagrid - Pass dynamic parameters & query data base on the parameters Post by: Franky on January 27, 2021, 12:47:40 AM Hi Jarry,
Thank you, that's work. However if I want it to initiate when the page first load, without needed to reload the datagrid, i now use queryParams. dg.edatagrid({ width:'auto', height:'auto', remoteSort:false, nowrap:false, fitColumns:true, striped:true, pagination:true, multiSort:true, url:'php/get_coo_data.php', queryParams:{bpID:login}, columns:[[ {field:'item',title:'Item',width:40,sortable:true}, {field:'desc1',title:'Desciption',width:100,sortable:true}, ]] }) |