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

[Solved] Edited Row highlight

7 Answers 261 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Meghna
Top achievements
Rank 1
Meghna asked on 23 Jul 2008, 05:38 AM
I want to highlight particular row once it is updated.  The row need to be highlighted with some different back color once it is updated. In which event i will do it and how?

7 Answers, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 23 Jul 2008, 07:21 AM
Hi Meghna,

I think that the example from this section of the documentation can become a good starting point for your custom implementation:

http://www.telerik.com/help/aspnet-ajax/grdselectedrowatalltimes.html

Feel free to extend/modify the solution to conform to your additional requirements.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Meghna
Top achievements
Rank 1
answered on 05 May 2009, 07:08 AM
Solution you have provided is not resolving my problem.

In my page, RadGrid is on left side panel and edit form is on right side panel. When I select any row in the grid it fires SelectedIndex event but row is still not in edit mode due to which I can not insert the Item data bound code in my code files.

I got few ideas from your post, I am able to get the row index of the row which is getting updated. But now i am unable to select this row from the binded RadGrid datasource.

I have tried both of the following ways

RadGrid1.MasterTableView.Items[(int)Session["selUserIndex"]].Selected = true;

RadGrid1.Items[(

int)Session["selUserIndex"]].Selected = true;

but giving following error

 

Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

Reason is paging, in items count gives the number of rows of particular page and the selected index count may exceeds this. I want to set the selected row from whole data source count and not the master table view items count.

0
Sebastian
Telerik team
answered on 05 May 2009, 07:17 AM

Hi Meghna,

Indeed in your scenario with paging enabled the grid's Items collection will contain the rows on the current page only (the same is true for the standard MS GridView control). If you would like to select an item on a different page, you will need to traverse the underlying data source, find the record in question, change the CurrentPageIndex of the grid (to navigate to this page), rebind it and then select the row there.

How to iterate through all items in the grid source you can see from this help topic:

http://www.telerik.com/help/aspnet-ajax/grdtotalsingridfooters.html (paragraph 'Displaying totals for all grid pages')

Regards,

Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Meghna
Top achievements
Rank 1
answered on 05 May 2009, 09:10 AM
Question 1: On which event I can change this page index,
Question 2: Also every time when I update the any row, the fresh data will come from database. I am able to retrieve the updated row in fresh datasource but how i am able to get the page on which this updated row will come.
e.g while updating it was on 1st page but after updation it might fall under page 4. Then how can i know the new page number.

0
Sebastian
Telerik team
answered on 05 May 2009, 09:22 AM
Hello Meghna,

  1. You can change the page index of the grid inside the PreRender server event of the grid and refresh it invoking its Rebind() method.
  2. The same approach with iterating through the items in the underlying data source should be applicable in this case. Then you can navigate to the page which holds the record using the technique from point 1.
Best,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Meghna
Top achievements
Rank 1
answered on 05 May 2009, 09:40 AM

Users

 

updatedUser = (Users)ViewState["ManageApplicationUserSelectedUser"];
for (int pageCount = 0; pageCount < RadGrid1.PageCount; pageCount++)

 

{

 

for (int rowCount = 0; rowCount < RadGrid1.MasterTableView.Items.Count; rowCount++)

 

{

 

if (updatedUser.ObjectGuid.Equals(RadGrid1.MasterTableView.Items[rowCount]["ObjectGuid"].ToString()))

 

{

RadGrid1.CurrentPageIndex = pageCount;

RadGrid1.MasterTableView.Items[rowCount].Selected =

true;

 

 

}

}

}

Above is my code snippet.
There I am traversing with each item of the RadGrid and comapring one of its cell value with my viewstate value. If its matches to true that means this particular row of RadGrid datasource is updated. Now my question is how can i get page for this row.
And onec i get the page i will rebind() the RadGrid. After that how am i get the rowcount of the updated user and how i navigate my paging to that particular page which contains this updated row.


Can you please provide small simple code snippet which i can integrate in my application.

0
Accepted
Princy
Top achievements
Rank 2
answered on 05 May 2009, 11:01 AM
Hello Meghna,

You can try out the following code to search for the updated item and set it selected:
c#:
            Users updatedUser = (Users)ViewState["ManageApplicationUserSelectedUser"]; 
   
            int flag = 0; 
            for (int i = 0; i < RadGrid1.MasterTableView.PageCount; i++) 
            { 
                RadGrid1.CurrentPageIndex = i; // set the page index to the current page 
                RadGrid1.Rebind(); 
 
                foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
                { 
                    if (updatedUser.ObjectGuid.Equals(dataItem["ObjectGuid"].Text )) //search for the updated text  
                    { 
                        dataItem.Selected = true//select the row  
                        flag = 1; 
                    } 
                } 
                if (flag == 1) 
                    break
            } 

Thanks
Princy.
Tags
General Discussions
Asked by
Meghna
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Meghna
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or