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

select first row on client-server binding

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 07 Sep 2011, 07:34 PM
I am replacing the grid in an existing page with a RADGrid
the page has a lot of functionality in a Javascript function on a select
if there is only one row I need to select it
how do I invoke the client select function from the server?
I tried this (below) - the function is hooked up but it doesn't "find" any of the objects

http://www.telerik.com/community/forums/aspnet-ajax/grid/fire-client-side-select-event-on-server-side.aspx

2 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 12 Sep 2011, 04:00 PM
Hello Marianne,

To achieve you goal, you can handle the OnGridCreated client-side event. There if sender.get_masterTableView().get_dataItems().length > 0, select the first item.
Chek it out and let me know if this works for you.


Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Elliott
Top achievements
Rank 2
answered on 12 Sep 2011, 05:51 PM
I implemented a handler for the OnMasterTableView

</MasterTableView>
<ClientSettings>
    <Selecting AllowRowSelect="true" />
    <ClientEvents OnRowSelected="ItemsRowSelected" />
    <ClientEvents OnMasterTableViewCreated="MasterTableViewCreated" />
</ClientSettings>
</telerik:RadGrid>


function MasterTableViewCreated(sender, eventArgs) {
    var theGrid = sender.get_masterTableView();
    var kount = theGrid.get_dataItems().length;
    if (kount == 1) {
        theGrid.selectItem(theGrid.get_dataItems()[0].get_element());
    }
}
Tags
Grid
Asked by
Elliott
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Elliott
Top achievements
Rank 2
Share this question
or