Arun Kumar
Top achievements
Rank 2
Arun Kumar
asked on 05 Aug 2011, 12:45 PM
Hi all,
I want to highlight row based on text entered in the textbox. Basically I load data from database and show it on the grid with self reference hierarchy relation. Initially grid is collapsed to first level (I have more than 5 sub levels). How do I do that?
Thanks
I want to highlight row based on text entered in the textbox. Basically I load data from database and show it on the grid with self reference hierarchy relation. Initially grid is collapsed to first level (I have more than 5 sub levels). How do I do that?
Thanks
6 Answers, 1 is accepted
0
Hello Arun,
Thank you for your question.
You can use ConditionalFormatting to highlight rows depending on a text in a textbox. Please review the following code snippet:
The formatting will apply to all level of self-reference hierarchy.
Best regards,
Alexander
the Telerik team
Thank you for your question.
You can use ConditionalFormatting to highlight rows depending on a text in a textbox. Please review the following code snippet:
ConditionalFormattingObject obj =
new
ConditionalFormattingObject(
"MyCondition"
, ConditionTypes.Contains, textBoxText,
""
,
true
);
obj.CellForeColor = Color.Red;
obj.RowBackColor = Color.SkyBlue;
this
.radGridView1.Columns[ColumnName].ConditionalFormattingObjectList.Add(obj);
The formatting will apply to all level of self-reference hierarchy.
Best regards,
Alexander
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Arun Kumar
Top achievements
Rank 2
answered on 11 Aug 2011, 08:49 AM
Hello Alexander,
Thanks for your reply. Its working fine but I want to expand rows to that row. I am tried with the following code but it takes more time to expand rows. The reason is it expands all rows instead of its child rows. Can you give me some idea to achieve this?
I would appreciate if you tell me how do I expand current selected row and its child rows?
Thanks
Thanks for your reply. Its working fine but I want to expand rows to that row. I am tried with the following code but it takes more time to expand rows. The reason is it expands all rows instead of its child rows. Can you give me some idea to achieve this?
For
Each
gvr
As
GridViewRowInfo
In
Me
.dgv.MasterTemplate.Rows
gvr.IsExpanded =
True
If
gvr.Cells(
"AcCode"
).Value.ToString() =
Me
.txtSearch.Text
Or
gvr.Cells(
"AcName"
).Value.ToString() =
Me
.txtSearch.Text
Then
Dim
tableElement
As
GridTableElement = TryCast(
Me
.dgv.CurrentView, GridTableElement)
gvr.IsSelected =
True
If
Not
tableElement
Is
Nothing
Then
tableElement.ScrollToRow(gvr)
End
If
Exit
For
End
If
Next
I would appreciate if you tell me how do I expand current selected row and its child rows?
Thanks
0
Hello Arun,
You can use a recursive algorithm to search the child rows of each first-level row in the self-reference hierarchy. This algorithm expands only the parent rows of the found row:
I hope it helps you to accomplish your requirements.
Best regards,
Alexander
the Telerik team
You can use a recursive algorithm to search the child rows of each first-level row in the self-reference hierarchy. This algorithm expands only the parent rows of the found row:
Private
Sub
FindRow()
For
Each
Row
As
GridViewRowInfo
In
Me
.radGridView1.MasterTemplate.Rows
If
Row.Cells(
"AcCode"
).Value.ToString() =
Me
.txtSearch.Text
Then
Row.IsCurrent =
True
Exit
For
End
If
Me
.SearchChildRows(Row)
Next
End
Sub
Private
Sub
SearchChildRows(
ByVal
Row
As
GridViewRowInfo)
For
Each
ChildRow
As
GridViewRowInfo
In
Row.ChildRows
If
ChildRow.Cells(
"AcCode"
).Value.ToString() =
Me
.txtSearch.Text
Then
ChildRow.IsCurrent =
True
Exit
For
End
If
Me
.SearchChildRows(ChildRow)
Next
End
Sub
I hope it helps you to accomplish your requirements.
Best regards,
Alexander
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Arun Kumar
Top achievements
Rank 2
answered on 12 Aug 2011, 09:02 PM
Thanks Alexander ,
It solved my issue.
It solved my issue.
0
Ed
Top achievements
Rank 1
answered on 18 Aug 2011, 03:21 PM
Thanks for your answer - it resolved my question too!
0
Hi guys,
Alexander
the Telerik team
I am glad to hear that you found my response helpful. Should you have additional questions, do not hesitate to contact me.
All the best,Alexander
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>