[ 10 posts ]

Chandra

  • Username: chandrakantab
  • Joined: Mon Mar 26, 2012 1:58 am
  • Posts: 3
  • IRC: ChandraDev
  • Offline
  • Profile

Retain Input value over different pages in paginator

Post Posted: Mon Mar 26, 2012 2:15 am
+0-
Hi,
I have a YUI datatable of multiple pages using paginator. I can retain the status of checkbox in all pages. But I am not able to retain the value of a text input field in all pages.

E.g - in one page I am inserting some value into text input field and I move to other pages. Then when I again come back to that page, the input field value is auto reset to the loading time.

Is there any way to handle that, even the input field object is also coming null for other pages.

my requirement: I will insert value to one input field in page 3 and in page 1 onclicking of submit button I should get the text inserted in page 3.

Thanks in advance.

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Mon Mar 26, 2012 8:31 am
+0-
When you paginate the DOM is destroyed and replaced, so the input field is gone. If you want to save the value, you have to catch the event from Paginator and save the value from the field.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Mon Mar 26, 2012 12:42 pm
+0-
I assume you are not using the built-in editor because if you did, the value would be preserved for you. As John has said, the DOM is destroyed on pagination because the DOM is just a reflection of what the DataTable stores internally in the RecordSet. The DOM is volatile, the RecordSet remains. What I disagree with John is that the field in the Record instance for the edited row has to be kept in synch at all times. The DOM is not only destroyed with pagination, sorting on a column will also destroy it and a few other actions also will so the rule is, as soon as something is updated, it should be reflected in the RecordSet, then whatever happens, it will be preserved and refreshed when paging through, sorting by column or whatever.

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Mon Mar 26, 2012 1:41 pm
+0-
Good point. If you allow sorting, then that also destroys the DOM, so the best solution is to use a cell editor.

Chandra

  • Username: chandrakantab
  • Joined: Mon Mar 26, 2012 1:58 am
  • Posts: 3
  • IRC: ChandraDev
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Mon Mar 26, 2012 11:46 pm
+0-
Thanks for your suggestions John, Satyam.

I understood that the dom object gets reset in each page and its client level. RecordSet once fetched remains. Got the cell edit feature of datatable. Thanks.

So basically it seems like we can't work on input fields with paginator or is there any way?

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Tue Mar 27, 2012 8:40 am
+0-
Yes you can use all sorts of controls in cells:

http://www.satyam.com.ar/yui/2.6.0/asso ... trols.html

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Tue Mar 27, 2012 9:21 am
+0-
But the state of those controls will not be persisted when you paginate or sort, unless you save the values yourself.

For example, QuickEdit (http://jafl.github.com/yui2/quickedit/) shows input fields in all the table cells, but it disables pagination, because you have to save before doing anything else.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Tue Mar 27, 2012 11:32 am
+0-
The whole point of the example is to show how to save the values of each control, not just how to show them.

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Retain Input value over different pages in paginator

Post Posted: Thu Apr 12, 2012 6:29 am
+0-
I built a YUI 3 Gallery module for saving state in a DataTable. It supports both form fields and widgets. It maintains the state, so you can save it when you want to. You are not forced to save it immediately.

http://yuilibrary.com/gallery/show/datatable-state

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile
Tags:

Re: Retain Input value over different pages in paginator

Post Posted: Thu Apr 12, 2012 9:07 am
+0-
I just realized that another option is to use gallery-bulkedit (http://yuilibrary.com/gallery/show/bulkedit). The examples show fields in all columns, but you could show read-only values in some columns, if you want.
  [ 10 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