Title: Is it correct behavior of datagrid? Post by: volodias on October 06, 2013, 10:29:47 PM Hello!
Please, check if the behavior of datagrid is correct. Or I do not understand something... If I un-comment lines 1,2 and 3 - I get on the server side 3 requests to the database, not 1 as I expect! Why it is so? If I use only lines 2 and 3 - thus, I see 2 database requests... If I use line 4 - I see only 1 database request, just what is needed. What can be wrong? If I add any code like $('#dg').datagrid - I get an extra database request, what is very unexpected. //1 $('#dg').datagrid({showHeader: false}); //2 $('#dg').datagrid({ url: 'jrnact.php?ent=inc' }); //3 $('#dg').datagrid('load',{ eid: value }); //4 $('#dg').datagrid({ url: 'jrnact.php?ent=inc', queryParams: { eid: value} }); Title: Re: Is it correct behavior of datagrid? Post by: stworthy on October 07, 2013, 01:33:39 AM Calling $('#dg').datagrid({ url: 'jrnact.php?ent=inc' }) will create datagrid and make a request('jrnact.php').
Calling $('#dg').datagrid('load',{ eid: value }) will make a new request with new parameter value. Calling $('#dg').datagrid({ url: 'jrnact.php?ent=inc', queryParams: { eid: value} }) will create datagrid again and make a request. Title: Re: Is it correct behavior of datagrid? Post by: volodias on October 07, 2013, 02:26:46 AM I have a datagrid created from markup.
The code of the lines1..4 is in the function which "feeds" this datagrid with data. How then to be sure that only one database request will be done? Unfortunately, do not very understand why my datagrid has to be created with every selector statement? Even if I like just to change only a property of the datagrid? - $('#dg-jrn').datagrid({showHeader: false}); What I have... ------------------------------------------------------------------------------- <table id="dg-jrn" title="Journal" class="easyui-datagrid" pagination="true" rownumbers="true" > <thead> <tr> <th field="jrn_dat" >Date</th> <th field="jrn_usrid" formatter=fmtUser>User</th> <th field="jrn_rec" >Text</th> </tr> </thead> </table> ---------------------------------------------------------------------------------- function editRecord(){ var row = $('#dg-jrn').datagrid('getSelected'); if (row){ idn = row.inc_idn; $('#inc_form').form('clear'); .... incLoadJrn(row.inc_id); .... url = 'incact.php?act=update'; } } ---------------------------------------------------------------------- function incLoadJrn(value){ //1 $('#dg-jrn').datagrid({showHeader: false}); //2 $('#dg-jrn').datagrid({ url: 'jrnact.php?ent=inc' }); //3 $('#dg-jrn').datagrid('load',{ eid: value }); //4 $('#dg-jrn').datagrid({ url: 'jrnact.php?ent=inc', queryParams: { eid: value} }); } |