Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Select Row on Client Side Javascript
posted

Hello!

I would like to select the first row of a WebDataGrid upon load in javascript.  I am calling the following function in the 'SelectionClientEvents -> Initialize' event.

function SelectRow()
{
var grid = document.getElementById('<%=wdgASNList.ClientID%>');
var gridRow = grid.get_rows().get_row(0);
grid.get_behaviors().get_selection().get_selectedRows().add(gridRow);
}

I am receiving the "Object doesn't support this property or method" error at
var gridRow = grid.get_rows().get_row(0);

Perhaps I am doing something wrong! 

Thanks for all the help!

John

Parents
No Data
Reply
  • 2783
    Suggested Answer
    posted

    Hi,

    In order to do this, handler the Grid's Initialize event instead, when you try to do it in the Selection's Initialize event, the behavior has not finished initializing yet.  You can do this like so:

     <ig:WebDataGrid ID="WebDataGrid1" runat="server" Width="400px" Height="400px">   
     <Behaviors>   
      <ig:Selection RowSelectType="Multiple"> </ig:Selection>
     </Behaviors>
          
     <ClientEvents Initialize="GridInit" /> 
    </ig:WebDataGrid>

    function GridInit(grid, evntArgs)
    {
     var row = grid.get_rows().get_row(0);
     grid.get_behaviors().get_selection().get_selectedRows().add(row);
    }

    Thank You,

    Olga

Children