This is a migrated thread and some comments may be shown as answers.

Firing Server Event on Column Resize

7 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 22 Oct 2010, 06:23 PM
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

7 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 26 Oct 2010, 03:10 PM
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
0
Bob
Top achievements
Rank 1
answered on 26 Oct 2010, 03:44 PM
Radoslav,

Thank you very much.  This is very helpful.

-Bob
0
Jamieson
Top achievements
Rank 1
answered on 25 Oct 2016, 04:27 PM

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.

0
Daniel
Telerik team
answered on 26 Oct 2016, 08:52 AM
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.
0
Jamieson
Top achievements
Rank 1
answered on 26 Oct 2016, 01:40 PM
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.  
0
Daniel
Telerik team
answered on 27 Oct 2016, 09:14 AM
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.
0
Jamieson
Top achievements
Rank 1
answered on 28 Oct 2016, 02:49 PM
Thank you for the clarification and details, they are very helpful.
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Bob
Top achievements
Rank 1
Jamieson
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or