Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: Adding new record in paginated datatable

Expand Messages
  • Asit Katiyar
    Hi Luke, thanks for the response, the code snippet fixed my problem.
    Message 1 of 3 , Aug 31 10:27 PM
    • 0 Attachment
      Hi Luke, 

      thanks for the response, the code snippet fixed my problem.

      On Wed, Aug 26, 2009 at 8:07 PM, y_lsmith <lucas.e.smith@...> wrote:
       

      --- In ydn-javascript@yahoogroups.com, Asit Katiyar <asitkatiyar@...> wrote:
      >
      > Hi,
      > I have a YUI datatable and in each row there is a "add" button. On-clicking
      > on the add button a new record adds at the bottom of the table. Now the
      > problem is when I apply pagination to the datatable and then try to add new
      > record, it adds at the last page (last page of pagination) of the datatable
      > and it seems nothing happened.
      > I want to be able to add the record on the current page section of the
      > datatable. Would be great if someone helps me out the get the solution.
      >
      > Thanks in advance.
      > YUI user.
      >

      http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_addRow

      addRow accepts an index argument as the second parameter. You can determine the appropriate index using the Paginator's current recordOffset plus rowsPerPage minus one.
      http://developer.yahoo.com/yui/docs/YAHOO.widget.Paginator.html#method_getStartIndex
      http://developer.yahoo.com/yui/docs/YAHOO.widget.Paginator.html#method_getRowsPerPage

      var pag = myDataTable.get('paginator');

      var addAtIndex = pag.getStartIndex() + pag.getRowsPerPage() - 1;

      myDataTable.addRow(NEW_ROW_DATA, addAtIndex);

      Hope this helps,
      Luke


    Your message has been successfully submitted and would be delivered to recipients shortly.