Is there a way to access grid from inside @code block?

4 posts, 0 answers
  1. Wei
    Wei avatar
    3 posts
    Member since:
    Apr 2008

    Posted 25 Nov 2019 Link to this post

    once a grid is declared in markup, and for columns that are sortable, reorderable and resizable. I want to persist that settting from grid UI and later apply those settings back to grid, in @code section (some event handler handles save column setting, apply column settings)?

    this requires @code block to be able to access the grid object and the columns inside it. it is possible? 

  2. Wei
    Wei avatar
    3 posts
    Member since:
    Apr 2008

    Posted 25 Nov 2019 in reply to Wei Link to this post

    I added @ref in grid markup and declared the grid in @code block. 

    this.grid.GridColumns

    this returns renderFragment object, how do I get each column and its properties

    thanks

  3. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5922 posts

    Posted 26 Nov 2019 Link to this post

    Hello Wei, 

    You can Follow the implementation of such a feature in the following page (I added your Vote for you): https://feedback.telerik.com/blazor/1414050-save-grid-layout. It would require a lot of other things as base though, such as programmatic filtering, sorting and so on (also available in our Feedback Portal if you want to follow them - here, here, here, here).

    The way to get information for columns is to define a view model with the data you want and use that to fill in the columns collection. A similar example is available in the following pages:

    You can use this approach to apply settings to the grid when it initializes, but extracting that information is mostly unavailable at the moment. You could handle the OnRead event to implement all read operations yourself, and to store the DataSourceRequest object from which you could extract information about filter, sort and group state, but it would not be easy, and information about column sizes and orders is not available there.

    Regards,
    Marin Bratanov
    Progress Telerik

     UI for Blazor
  4. Wei
    Wei avatar
    3 posts
    Member since:
    Apr 2008

    Posted 26 Nov 2019 in reply to Marin Bratanov Link to this post

    Thanks for the answer, I think we will wait for Telerik team to expose the proper API for column setting read and apply to implement this function in our project. 
Back to Top