[ 5 posts ]

AliRamezani

  • Joined: Fri Jan 20, 2012 5:06 am
  • Posts: 8
  • Offline
  • Profile

YUI3 DataTable addRows without rerendering the datatable obj

Post Posted: Thu Jun 14, 2012 11:32 pm
+0-
Hello,

i have a rendered datatable instance with extended serverside paging and want to remove all existing rows and add new ones which is coming from server without rerendering my datatable instance.

this ist my code to do this task:

Code:

                this._dataTable.data.reset();
                this._dataTable.data.add(data, { silent: true });
                this._dataTable.syncUI();


and it works very fine and with a good performance,

but i have a problem with the sorting after this lines.

while the new datatable is created, it works well and quickly, but after paging it always takes longer and sorting is only possible in one direction and toggling the sort direction doesnt work anymore.

anyone know why?

Thank you and YUI3 framework is fantastic. Thank you for this.


Last edited by AliRamezani on Tue Jun 19, 2012 12:02 am, edited 2 times in total.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 514
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: YUI3 DataTable addRows without rerendering the datatable

Post Posted: Mon Jun 18, 2012 11:00 am
+0-
(Aside) You can just do this._dataTable.reset(data, { silent: true }).syncUI()

You're saying the sorting is slower after resetting the data? And I'm confused about your reference to both scrolling and pagination. Are you using a paginator module from the gallery, rolling your own, or something else? Are you using datatable-scroll with vertical scrolling as well?

If you can link to more code in a gist, jsfiddle, or jsbin.com/3/ that would be helpful.

AliRamezani

  • Joined: Fri Jan 20, 2012 5:06 am
  • Posts: 8
  • Offline
  • Profile

Re: YUI3 DataTable addRows without rerendering the datatable

Post Posted: Mon Jun 18, 2012 11:54 pm
+0-
Hello

here you can reproduce my problem:

http://jsfiddle.net/Ali_Ramezani/qmvTe/11/

after switching the data you can not sort correctly.

and how can I prevent the client-side sorting, without losing sorting behavior? CSS clickable columns, etc.
thank you :-)

AliRamezani

  • Joined: Fri Jan 20, 2012 5:06 am
  • Posts: 8
  • Offline
  • Profile

Re: YUI3 DataTable addRows without rerendering the datatable

Post Posted: Wed Jul 04, 2012 12:39 am
+0-
it seems to be working with the new release

http://yui.yahooapis.com/3.6.0pr3/build/yui/yui-min.js

but how can i prevent the client-side sorting? see my last question.

thank you.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 514
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: YUI3 DataTable addRows without rerendering the datatable

Post Posted: Wed Jul 04, 2012 8:34 pm
+0-
You need to prevent the 'sort' event, then call the server with the sort request info. In the handler for the server response, reset() the table's data with the response data, then set the sortBy attribute to the requested sort order.

Here's an example: http://jsfiddle.net/ls_n/PV3r4/
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum