Client-Side Row Selection Persisted With Paging

Thread is closed for posting
4 posts, 1 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 15 Nov 2006 Link to this post

    Requirements

    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version
    4.0.2 and later


    2008.1.415 and later
    .NET version

    2.0 and later

    Visual Studio version

    2005 and later

    Programming language Javascript, C#
    Browser support

    all supported by RadGrid for ASP .NET


    all browsers supported by RadControls for ASP .NET AJAX


     
    PROJECT DESCRIPTION
    In some scenarios you may want to select rows in r.a.d.grid, then use paging to view another grid page and on return to have the previously selected rows preserved. Using the client-side selection mechanism this can be achieved by saving the selected rows indexes in a client-side hash object with key the PageIndex. When the GridCreated client-side event is raised the selected rows for the current page are restored from the hash. As the javascript objects are not persisted after postbacks, the hash is saved in a hidden input field and on every page load its value is restored.
  2. Petja
    Admin
    Petja avatar
    631 posts

    Posted 21 Feb 2007 Link to this post

    PROJECT DESCRIPTION of Client-Side Row Selection Persisted With Paging and Sorting (project attachment name: pagingsortingwithclientsideselecting-classic.zip)

    The project demonstrates how client-side selecting can be preserved with paging and sorting functionality. Using the client-side selection mechanism the selected rows indexes are saved in a client-side hash object with key the PageIndex. When the GridCreated client-side event is raised (when the request from the server is over) the selected rows for the current page index are restored from the client-side hash.
    As the sorting changes the item indexes in the pages, we need to update them on every sort. That is why we need a unique id of every item and use two Hashtable server-side objects:
    - selectedItemsPerPage - save the unique ids of all selected items per page, i.e. key=pageIndex, value=selectedItemsIds per the corresponding page index, separated by comas;
    - selectedIndexesPerPage - the same like the above object, but with value the corresponding item indexes per page (to update the client-side hash object with its value by pass its value the a hidden input field).
    On PreRender server-side event handler we pass the value of the selectedIndexesPerPage only for the current page index of the grid. On every request to the server (on Sort and Page) we save the current page selected indexes and their unique ids in the both Hashtables. On Sort we update the selectedItemsPerPage and selectedIndexesPerPage keys and values due to the selected items unique ids and corresponding to the new ordered grid data source.
    As the JavaScript objects are not persisted after postbacks, the client-side hash object value is saved in a hidden input field and on every page load its value is restored. To preserve the value of the both Hashtables, we save/get them in/from two Session objects.


    Best wishes,
    Petja Vassileva
    the telerik team
  3. Answer
    ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 15 Mar 2009 Link to this post

    ok guys every time a run my project a java script error saying that grid.CurrentPageIndex is not initialised or is not an object...please help
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 27 May 2009 Link to this post

    Hello Guys,

    I have attached an updated version of the project, which works with RadControls for ASP.NET AJAX.

    Kind regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top