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

Telerik RadGrid OnRowSelected Event

1 Answer 355 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Levi
Top achievements
Rank 1
Levi asked on 15 Sep 2011, 01:19 AM
I have a RadGrid with multiple select enabled:

<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowMultiRowSelection="true">
    <MasterTableView TableLayout="Fixed">
        <Columns>
            <telerik:GridBoundColumn DataField="Dialog" HeaderText="Dialog" DataType="System.String" />
        </Columns>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="True" />
        <ClientEvents OnRowSelected="RowSelected"/>
    </ClientSettings>
</telerik:RadGrid>

And the OnRowSelected event triggers for each row selected. When selecting 10 rows, the event gets fired 10 times. Simple enough.

My question is what event can I listen to to know when all the rows that are going to be selected are selected (as a result of the multiple selection)? I need to make a post request with the ids of the selected rows and I don't think it's a good idea to let 10 post request be made. I can query the grid to get the selected rows, I just need to know when to do it; ideally something that doesn't involve timeouts. There must an event for this that I'm overlooking.

1 Answer, 1 is accepted

Sort by
0
Levi
Top achievements
Rank 1
answered on 16 Sep 2011, 03:06 PM
Never mind, I got something working with timeouts. Would be nice to have an additional event for when all the rows that are going to be selected are selected as a result of shift-click or click-drag. I don't imagine it would be too difficult to setup considering deep down in the bowels of the telerik javascript a loop is iterated to select all the rows. Just a little, 'hey, we're done selecting all the rows' event after the loop is done would be nifty.

I'm hoping 10 milliseconds will be sufficient across all browsers and platforms.

var rowSelectedTimeout;
 
function RowSelected(rowObject) {
    if (window.rowSelectedTimeout) {
        // If selecting multiple rows, clear the previous row's rowSelectedTimeout
        window.clearTimeout(window.rowSelectedTimeout);
    }
 
    rowSelectedTimeout = window.setTimeout(function () {
        window.rowSelectedTimeout = null;
 
        alert('rows selected');
    }, 10);
}
Tags
Grid
Asked by
Levi
Top achievements
Rank 1
Answers by
Levi
Top achievements
Rank 1
Share this question
or