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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Various selection/display issues

Thread ID:

Created:

Updated:

Platform:

Replies:

146467 Aug 5,2019 01:32 PM UTC Aug 7,2019 04:50 PM UTC ASP.NET Web Forms 1
loading
Tags: Grid
Bob Needham
Asked On August 5, 2019 01:32 PM UTC

Hi

I have a few issues with the asp.net web forms Grid control, id appreciate some help please

1) the ServerRowDeselected event never seems to fire

2) when I click the header to sort it deselects the current row (so none are selected) but as it doesn’t seem to raise an event I can’t reset my internal ‘SelectedIndex’ flag to -1, how do I do this?. Im sure at sone time clicking the header kept the current item selected, but I think I must have changed a setting somewhere or my update panels are getting in the way – any ideas?

3) I can’t find how to check what the current grid selected row or index is programatically in my c# code behind - all examples seem to Do it in an event. And am pretty much a newbie to javascript and need to learn more, so if you are giving a javascript example please also tell me how I get the appropriate values into my code behind

4) How do I programmatically select a row on one of the grid pages and ensure its visible, eg after a new row is inserted mid way in the list

ive attached my test page to give you an idea where im at

many thanks in advance

Bob


Attachment: GridIssues_ad271071.zip

Padmavathy Kamalanathan [Syncfusion]
Replied On August 7, 2019 04:50 PM UTC

Hi Bob, 
 
Thanks for contacting Syncfusion Forums. 
 
QUERY1: the ServerRowDeselected event never seems to fire 
 
From your query we understand that, the OnServerRowDeselected event doesn’t fires. When you use both OnServerRowSelected, OnServerRowDeselected event , select a row, the OnServerRowSelected event will be triggered. When you select another row, the OnServerRowDeselected event will not be triggered for the deselected row, instead the  OnServerRowSelected event will be triggered for newly selected row. This is the behavior of grid. 
 
QUERY2: when I click the header to sort it deselects the current row (so none are selected) but as it doesn’t seem to raise an event I can’t reset my internal ‘SelectedIndex’ flag to -1 
 
When you select and sort the grid, the grid rows get sorted, which means the row you have selected could have been in different page. After sorting, you no longer do any operation with that selected row, since it may not be in the current page. You have mentioned that you need to set internal flag. Please do clarify your requirement and scenario, so that we could help you to achieve it. 
 
QUERY3: I can’t find how to check what the current grid selected row or index is programmatically in my c# code behind 
 
You can set a button, bind OnClick event to it, and get the current grid selected row from GridId.SelectedRowIndex in code behind. 
 
Please refer the below code snippet, 
 
 
            <ej:Button ID="btn_Click" runat="server" OnClick="btn_Click_Click" Size="Normal" Text="Click to Select"></ej:Button> 
            <ej:Grid ID="OrdersGrid" runat="server"  
                   ----------- 
                <Columns> 
                      ---- 
                </Columns> 
            </ej:Grid> 
 
In code behind 
 
        protected void btn_Click_Click(object Sender, ButtonEventArgs e) 
        { 
            if(OrdersGrid.SelectedRowIndex != -1) {  
               // GridId. SelectedRowIndex will give selected rownindex 
                 -------- 
            } 
        } 
 
 
 
Please refer the below screenshot, 
 
 
 
QUERY4: How do I programmatically select a row on one of the grid pages and ensure its visible 
 
For selecting the last added row, you can call SelectRows method and pass the index of newly added record to that method in actioncomplete event with args.requestType as “save” and args.action as “add” to select the newly added row. 
 
Please refer the below code snippet, 
 
 
   <script> 
        function complete(args) { 
           if (args.requestType == "save" && args.action == "add") { 
              this.selectRows(index); // index= index of newly added row 
                        } 
                    } 
   </script> 
 
 
 
If you are unable to achieve this result, please do clarify us how you are inserting row in grid, so that we can help you to achieve your query. 
 
If you have further queries, please get back to us. 
 
Regards, 
Padmavathy Kamalanathan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon