Author Topic: Problem adding data  (Read 2732 times)

emontes

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Problem adding data
« on: June 11, 2016, 05:08:39 am »
I followed the example in http://paramquery.com/pro/demos/editing_instant

Everything works fine, but when I try to add an Item and is needed a new page the grid don't go to the page, in a previous post http://paramquery.com/forum/index.php?topic=1517.msg6597#msg6597 you helped me to change the remote data  paging, then in my toolbar I have:
 {
               type: 'button',
                icon: 'ui-icon-plus',
                label: 'Nuevo Tema',
                listener: function () {
                    //append empty row at the end.                           
                    var rowData = { topicname: 'nuevotema', topictext: 'Nuevo Tema' }; //empty row
                    var rowIndx = grid.addRow({ rowData: rowData });
                    grid.goToPage({ rowIndx: rowIndx });
                    grid.editFirstCellInRow({ rowIndx: rowIndx });
                }
            },

and in my dataModel,
 beforeSend: function(a, b) {
               b.url = b.url.replace("pq_curpage", "page");
            }, 

Then I supose that the problem is with the grid.goToPage. How can I make the grid to take the page ?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Problem adding data
« Reply #1 on: June 13, 2016, 09:42:52 am »
Since auto save demo is based on local paging while you have been using remote paging, you can't expect same results.
You may require to make appropriate changes in your code.

Please check the value of rowIndx returned by addRow() method and compare it with number of records per page,

You may try to pass page number to goToPage() method instead of rowIndx
« Last Edit: June 13, 2016, 09:45:24 am by paramquery »

emontes

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Problem adding data
« Reply #2 on: June 14, 2016, 05:43:16 am »
which method can I use to get the Last Page of the Grid?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Problem adding data
« Reply #3 on: June 14, 2016, 01:45:09 pm »
That would be:

Code: [Select]
  grid.goToPage( { page: grid.option('pageModel.totalPages') } );