Selected Row after Reload?

12 posts, 1 answers
  1. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 14 Nov 2016 Link to this post

    Hi,

    what's the best and easiest way to save the selected row, make a refresh/reload and select the row again?

    var grid = $("#grid").data("kendoGrid");
            // here I want to save the selected row/id (in a variable?)
            grid.dataSource.read();
            // re-select the previous "saved" row
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 15 Nov 2016 Link to this post

    Hello,

    You can use the dataBound event and select the row with the select method.

    Regards,
    Kiril Nikolov
    Telerik by Progress
     
    Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
     
  3. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 15 Nov 2016 in reply to Kiril Nikolov Link to this post

    Hi,

    but how to do this - there are many postings with different Solutions how to select a row (uid, id...)?

    if you look at my Code sample above, before the "read" I want to save the current selection, then make a reload , and then select

    the previous saved selection...

    robert

     

  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 15 Nov 2016 Link to this post

    Hi,

    Check the following example:

    http://dojo.telerik.com/UcojU

    Regards,
    Kiril Nikolov
    Telerik by Progress
     
    Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
     
  5. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 15 Nov 2016 in reply to Kiril Nikolov Link to this post

    Hi Kiril,
    Thanks for your solution, but with that solution I have to loop through all items in every Change Event to save the selected item and also on the dataBound Event to (re)select the item (slow maybe a performance problem?).
    In my grid I have only single selection; so is this the only possible solution or is there a for singe selection without Looping through all items?
    robert
  6. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 15 Nov 2016 in reply to Robert Madrian Link to this post

    found it

    var grid = $("#grdFachgruppenzugehörigkeit").data("kendoGrid");
    var row = grid.select();
    grid.dataSource.read();
    grid.select(row);
  7. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 15 Nov 2016 in reply to Robert Madrian Link to this post

    sorry for the last post - after testing this dosn't work :-(
  8. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 16 Nov 2016 Link to this post

    Hi,

    If you have single selection, then persists just the single item:

    http://dojo.telerik.com/UcojU/5

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. Robert Madrian
    Robert Madrian avatar
    229 posts
    Member since:
    Apr 2003

    Posted 16 Nov 2016 in reply to Kiril Nikolov Link to this post

    Hi, thanks for the Solutions...

    this works with models which have a one Primary key (id) - is this not possible with Composite keys or is it necessary to build a single id in the model?

    robert

  10. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 16 Nov 2016 Link to this post

    Hi,

    Just use any unique field from the model, to persist the item.

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  11. Jairo
    Jairo avatar
    7 posts
    Member since:
    Dec 2019

    Posted 20 Feb in reply to Kiril Nikolov Link to this post

    Good day this same case in kendo grid MVC, how would it be?
  12. Anton Mironov
    Admin
    Anton Mironov avatar
    206 posts

    Posted 23 Feb Link to this post

    Hello Jairo,

    In order to achieve the desired behavior, I would recommend using the "persistSelection" property of the Kendo UI Grid. This approach will keep the selected row/s out of the box.

    Give a try to the persistSelection property and let me know if this is the expected behavior.

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top