EasyUI Forum

General Category => Bug Report => Topic started by: hande89 on June 17, 2014, 04:16:12 AM



Title: Datagrid pagination and appendRow
Post by: hande89 on June 17, 2014, 04:16:12 AM
The appendRow function seems to add row to the current page. Shouldn't the row be added to the last page if pagination is used and the rows are unsorted?


Title: Re: Datagrid pagination and appendRow
Post by: jarry on June 17, 2014, 09:17:47 AM
The appendRow method append a new row to the current page. To append to other page, you have to change the grid page before calling this method.


Title: Re: Datagrid pagination and appendRow
Post by: hande89 on July 16, 2014, 05:30:34 AM
Even if I navigate to the last page (which has fewer rows than my page size limit), append row and call acceptChanges method, the new row is not there when I visit first page and come back.

I have this example: http://www.jeasyui.com/easyui/demo/datagrid/rowediting.html with setting pagination:true and loadFilter:pagerFilter method from here: http://www.jeasyui.com/easyui/demo/datagrid/clientpagination.html


Title: Re: Datagrid pagination and appendRow
Post by: jarry on July 16, 2014, 06:32:24 PM
If you are using the 'pagerFilter' and wish to call 'appendRow' method on a datagrid, you have to override this method to support client side pagination. Here is the simple code to achieve this functionality.
Code:
    var appendRow = $.fn.datagrid.methods.appendRow;
    $.extend($.fn.datagrid.methods, {
      appendRow: function(jq,row){
        return jq.each(function(){
          var data = $(this).datagrid('getData');
          if (data.originalRows){
            data.originalRows.push(row);
          }
          appendRow.call($.fn.datagrid.methods, $(this), row);
        })
      }
    })