EasyUI Forum
May 20, 2024, 02:39:19 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datagrid pagination and appendRow  (Read 10416 times)
hande89
Jr. Member
**
Posts: 56


View Profile
« 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?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 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.
Logged
hande89
Jr. Member
**
Posts: 56


View Profile
« Reply #2 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 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);
        })
      }
    })
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!