Firing Server Event on Column Resize

8 posts, 1 answers
  1. Bob
    Bob avatar
    10 posts
    Member since:
    Jun 2010

    Posted 22 Oct 2010 Link to this post

    Hello,

    I need to fire a server event that will save the grid state  to a database when a grid column is resized.  I have gone through the forums and it seems the way to accomplish is by firing an ajax request, but I can't any sample code that shows how to do do this.  If anyone has expierance with this and could post a code sample, I would really appreciate it.   I am using an AjaxManagerProxy in a user control with the AjaxManager on a master page. 

    Thanks,
    Bob
  2. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 26 Oct 2010 Link to this post

    Hi Bob,

    To achieve the desired functionality you could handle the client side OnColumnResized event and fire the RadGrid command:
    <telerik:RadGrid ShowHeader="true" runat="server" ID="RadGrid1">
      <ClientSettings>
          <Resizing AllowColumnResize="true" />
          <ClientEvents OnColumnResized="OnColumnResized" />
      </ClientSettings>
    </telerik:RadGrid>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      <script type="text/javascript">
        function OnColumnResized(sender, eventArgs)
        {
            var columnWidth = eventArgs.get_gridColumn()._columnResizer._currentWidth;
            $find("<%= RadGrid1.ClientID %>").get_masterTableView().fireCommand("customCommand", columnWidth);
        }
      </script>
    </telerik:RadCodeBlock>

    Then on server side into the RadGrid.ItemCommand event handler you could check if the command name is customCommand and update the database:
    void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "customCommand")
            {
               //Update the database
            }
        }

    Additionally I am sending you a simple example. Please check it out and let me know if it helps you.

    Best wishes,
    Radoslav
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    10 posts
    Member since:
    Jun 2010

    Posted 26 Oct 2010 Link to this post

    Radoslav,

    Thank you very much.  This is very helpful.

    -Bob
  5. Jamieson
    Jamieson avatar
    3 posts
    Member since:
    Mar 2014

    Posted 25 Oct Link to this post

    Using this approach to call the savestate method of the RadPersistenceManager to save the state of the grid appears to somehow reverse the methods called if you override the storage provider to store in the database.  Happening in 2016.3 ASP..NET Ajax.

    It should call save state when you call save state, but instead it calls load state.  It appears depending on where the save state is called from sometimes it calls load state and vice versa.  Could this be because of when its called in the page lifecycle?  I am trying to think of any reasons this might happen by design.

  6. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 26 Oct Link to this post

    Hello Jamieson,

    I have replied to your support ticket. Basically, it is expected that the persistence framework may need to load the settings before save as it needs to merge them. As to the problem where the state is not saved at all, I will be able to respond when I get a runnable example as this is not something we are aware of.

    Regards,
    Daniel
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  7. Jamieson
    Jamieson avatar
    3 posts
    Member since:
    Mar 2014

    Posted 26 Oct in reply to Daniel Link to this post

    I wasn't able to find in the documentation this intended functionality.  Can you please reference the article that details why and when this might happen?  It might have saved a few hours of troubleshooting, and prevented a workaround.  
  8. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 27 Oct Link to this post

    Hello Jamieson,

    I'm afraid this behavior is not mentioned in the documentation. I will ping our support to update it in a timely manner. Simply put, if you have persister proxies with unique keys SaveState method will trigger LoadStateFromStorage in your storage provider.
    To give you a more real world example, this mostly happens when you have a master page and content pages that use persistence manager/proxy setup.
    I have updated your Telerik points as a token of gratitude for pointing us to the missing bits in the documentation.

    Regards,
    Daniel
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  9. Jamieson
    Jamieson avatar
    3 posts
    Member since:
    Mar 2014

    Posted 28 Oct in reply to Daniel Link to this post

    Thank you for the clarification and details, they are very helpful.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017