|
Title: [probably a bug]datagrid won't clear after getting empty rows from response Post by: unclerayray on November 09, 2013, 09:59:09 PM I'm using version 3.3 of easyui for a CMS. It's a SSH structured project.
I got a datagrid defined like this: Code: <table id="dg" class="easyui-datagrid" pagination="true" pageSize=20 anyway the filter function is wrote like this. Code: var con = $('#confirm').combobox('getValue');I got test data records in my db so there are always records showed in the datagrid when first loading. It all goes well, so that means I did get the datagrid well defined. However something very strange happened when I was testing the filter function, the datagrid won't refresh to a empty one when I got empty json rows from response. It remains the same before filtering instead. the response goes like this: Code: {'success':true,'message':'','total':0,'rows':[]}I did a test from server side, to change the json response to Code: {'success':true,'message':'','total':0,'rows':[]}Code: $('#dg').datagrid('load', {confirmed : con, follow : fol});This Code: $('#dg').datagrid('loadData', {'success':true,'message':'','total':0,'rows':[]});So I'm thinking the 'load' function of datagrid didn't remove the old rows before setting new rows. If there is a removal, It certainly didn't work in the empty row case. I could have look in the source code to find out why, only I'm pretty new in JS and the source code wasn't that readable. I'm there is no commont at all and all the functions are named with number and all. So here I'm. Looking for help! ;D Any suggestion will be appreciated. Title: Re: datagrid won't clear after getting empty rows from response Post by: stworthy on November 09, 2013, 10:50:27 PM Please refer to http://www.jeasyui.com/tutorial/datagrid/datagrid24.php. It works well.
Title: Re: datagrid won't clear after getting empty rows from response Post by: unclerayray on November 10, 2013, 12:12:39 AM Please refer to http://www.jeasyui.com/tutorial/datagrid/datagrid24.php. It works well. I know it works. And I certainly knows how to define a datagrid. The thing is I think there may be a bug here. When got empty rows from server, datagrid should be able to clear and show a empty one, not stay where it used to be, right?Title: Re: [probably a bug]datagrid won't clear after getting empty rows from response Post by: stworthy on November 10, 2013, 12:56:54 AM For the previous example, please enter some query parameter values that fetch empty data, the datagrid will clean all the rows.
http://www.jeasyui.com/tutorial/datagrid/datagrid24_demo.html Title: Re: [probably a bug]datagrid won't clear after getting empty rows from response Post by: unclerayray on November 28, 2013, 08:22:56 AM For the previous example, please enter some query parameter values that fetch empty data, the datagrid will clean all the rows. http://www.jeasyui.com/tutorial/datagrid/datagrid24_demo.html It took me so long to find out... turns out I was returning a json string with the character [ ' ] not [ " ] when total amount is 0. instead of returning {"success":true,"message":"","total":0,"rows":[]} it returns {'success':true,'message':'','total':0,'rows':[]} and datagrid couldn't parse it. It never throw any error though. So I think easyui should throw any error or hint, to remind people that they've got a json string with the wrong format |