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

Trapping configuration changes

5 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 29 Mar 2012, 04:00 PM
I have code that saves the state of a grid, but I need to do the save whenever the grid is changed by:
        resizing a column
        moving a column
        hide/show a column
        sorting
        grouping
        etc...

Where can I trap these changes?

5 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 04 Apr 2012, 06:36 AM
Hello Ron,

As you know, sorting and grouping will fire server-side events, so saving the grid state in this case should not be a problem. As for the client operations, you could, for example, capture the respective client-side events and fire a custom command that will trigger the ItemCommand server-side event.
The client events you are looking for are:

Resizing: OnColumnResized

Reordering: depending on your logic, there are a few options: OnColumnSwapped, OnColumnMovedToRight, OnColumnMovedToLeft

Show/hide: OnColumnHidden, OnColumnShown

And from each event, you could fire a command event through the fireCommand client method of the GridTableView object.
Alternatively, if this is an AJAX-enabled scenario, you could use the ajaxRequest method of the RadAjaxManager/Panel to trigger the server-side AjaxRequest event.

Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Thomas
Top achievements
Rank 1
answered on 04 Apr 2012, 11:52 AM
Is there any kind of example that would show some or all of these events/methods?

I'm afraid that I have not needed to use client side events up to this point, so I do not know how to implement your advice.
0
Thomas
Top achievements
Rank 1
answered on 04 Apr 2012, 02:01 PM
I have something working, an example would be nice, but low priority...
0
Thomas
Top achievements
Rank 1
answered on 04 Apr 2012, 02:45 PM
OK - I was incorrect, my solution does not work...
I added the following javascript:

 

function RadGridConfigurationChangedColumn(sender, eventArgs) {

 

 

var column = eventArgs.get_gridColumn();

 

 

var grid = column._owner;

 

RadGridConfigurationChangedCommand(grid);

}

 

function RadGridConfigurationChangedCommand(grid) {

 

 

if (grid != null) {

 

grid.fireCommand(

"RadGridConfigurationChanged", "");

 

}

}
and the following to the ClientSettings of the nested view template.

 

 

<ClientEvents OnColumnResized="RadGridConfigurationChangedColumn"

 

 

OnColumnSwapped="RadGridConfigurationChangedColumn"

 

 

 

 

 

OnColumnMovedToLeft="RadGridConfigurationChangedColumn"

 

 

 

 

 

OnColumnMovingToRight="RadGridConfigurationChangedColumn"/>

 

 

 

This does work in that my server side code (itemCommand) is called, but I am getting Javascript errors

 

'this._owner.get_masterTableView().ColGroup' is null or not an object'
or '_events' is null or not an object

I am using AJAX, but I don't see how to figure out the current detail grid from an ajaxRequest.

 

 

 

0
Tsvetina
Telerik team
answered on 09 Apr 2012, 01:21 PM
Hi Ron,

I am attaching the latest version of the sample project that I sent to you in the formal support ticket that you opened, in case anyone else needs such functionality. If you have any comments or questions, please share them in the ticket, so that we avoid double posts on the same problem.

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or