We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Select row through javascript

I have got a function that selects a row and then move scrolled to show it. Moving scroller is working fine, but selecting row it is not working.  How can I select row in grid on client side?

My function looks like this:

        function rowSelect_Show() {
            var obj = $("#Grid1").ejGrid("instance");
            var rowHeight = obj.getRowHeight();
            var selectedRowIndex = 12;
            obj.getScrollObject().scrollY(rowHeight * selectedRowIndex);
            obj.model.selectedRowIndex = selectedRowIndex;
            var objDt = $("#Grid1").data("ejGrid");
            objDt.selectedRowsIndexes.push(selectedRowIndex);
        }

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team September 22, 2016 07:35 AM UTC

Hi Mirza, 

Thanks for contacting Syncfusion support. 

To select a row in the grid, use selectRows method of ejGrid.  

Find the code example and sample: 


<ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowScrolling="true"> 
        <ScrollSettings Height="300" Width="500" ></ScrollSettings> 
        <Columns> 
                ---------------------------------- 
            </Columns> 
        <ClientSideEvents Create="create" /> 
        </ej:Grid>  
 
<script> 
    function create(args) { 
        var obj = $('#<%= Grid.ClientID %>').data("ejGrid"); 
        var rowHeight = obj.getRowHeight(); 
        var selectedRowIndex = 11; 
        obj.getScrollObject().scrollY(rowHeight * selectedRowIndex); 
        obj.selectRows(selectedRowIndex); 
    } 
</script> 


Refer to the Help document for the selectRows method.  


Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon