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

RadGrid SelectedItems without ViewState

2 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Greenberg
Top achievements
Rank 1
Mark Greenberg asked on 14 Oct 2009, 10:58 PM
Hello,

I have a RadGrid with 500 records per page and am trying to use the GridClientSelectColumn in conjuntion with the SelectedItems property on the server side.  Given the big page size, I have to have ViewState turned off.  This in turn results in 0 for the value of the SelectedItems property.  Can you please point me to a sample that provides a work around?

Thanks,
Chris

2 Answers, 1 is accepted

Sort by
0
Mark Galbreath
Top achievements
Rank 2
answered on 15 Oct 2009, 07:07 PM
Hey Chris,

I had the same issue and no one at Telerik responded.  So what I did was invoke the OnRowClick method in the radGrid definition (sorry about the formatting - this telerik online editor sucks)

 

<ClientSettings

 

<ClientEvents OnRowClick="onRowClick" />

 

 

 

 

 

 

</ClientSettings>
in the aspx <telerik:radGrid> node, and set the OnAjaxRequest property to

 

<

 

 

 

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

Then, in the JavaScript function I found the grid (table) row that was selected:

function
onRowClick( sender, args ) {

 

        var table_id = sender.ClientID

 

 

 

       var array_ = new Array()

 

 

          array_ = table_id.split( /[_]/ );

 

        var table = array_[ 3 ];

 

 

 

 

        switch( table ) {

 

                case "Groups" :

 

 

 

                        var masterTable = $find( "<%= rad_Groups.ClientID%>" ).get_masterTableView();

 

 

 

                        var datum = masterTable.getCellByColumnUniqueName( masterTable.get_dataItems()[ args.get_itemIndexHierarchical
                                () ],
"groups_group_name" ).innerHTML;

 

 

 

                        break;

 

 

 

                //  etc.
}

 

 

 v

ar ajaxManager = $find( "<%= RadAjaxManager1.ClientID %>" );

 

 

 ajaxManager.ajaxRequest( datum );

}

AjaxManager then makes an asyncronous call to the server and sends the datum to

Protected
Sub RadAjaxManager1_AjaxRequest( sender As Object, e As AjaxRequestEventArgs ) _ 
        Handles RadAjaxManager1.AjaxRequest

 

        Dim temp_array() As String = Split( e.Argument, "|" )

 

 

 

        Try

 

 

 

 

                Select Case temp_array.Length

 

 

 

                       Case Is = 1

 

 

                        Session(

"groupName") = e.Argument

 

 

 

               Exit Select

 

 

 

 

        Catch ex As Exception
                RadAjaxManager1.Alert( "Doh!" )
        End Try

Where you can manipulate the datum; in my case, I set a session variable so that I can then insert, delete, update on the server side (which I found necessary if you are using object data sources because the Telerik documentation is so lame and no one there seems to know how to use object data sources).

Hope this helps,
Mark

 

 

 

 

 

 

 

 

 

0
Schlurk
Top achievements
Rank 2
answered on 15 Oct 2009, 10:06 PM
As a note about the editor comment: You are able to press the "Format Code block" icon between the broken link image and the spell check image. This way you can auto-format the code any way you like and it's contained within a nice scrollable area :D
Tags
Grid
Asked by
Mark Greenberg
Top achievements
Rank 1
Answers by
Mark Galbreath
Top achievements
Rank 2
Schlurk
Top achievements
Rank 2
Share this question
or