Hi,
I need to apply conditional formatting of items, but based on values in the row which arent being bound. How do I do this, which event is it I can capture which gives me access to the underlying row, not just the cells being bound - and how do I get a reference to a cell in this method so I can apply my formatting.
Regards
Indy
I need to apply conditional formatting of items, but based on values in the row which arent being bound. How do I do this, which event is it I can capture which gives me access to the underlying row, not just the cells being bound - and how do I get a reference to a cell in this method so I can apply my formatting.
Regards
Indy
9 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 24 Apr 2008, 05:58 AM
Hi Stephen,
Check out the following help document links.
Customizing row appearance
Conditional Formatting for rows/cells on ItemDataBound
Shinu.
Check out the following help document links.
Customizing row appearance
Conditional Formatting for rows/cells on ItemDataBound
Shinu.
0
Stephen
Top achievements
Rank 1
answered on 24 Apr 2008, 09:02 AM
Hi,
I am using ItemDataBound now. The only problem is I need to access an element in the underlying row of data in the database, not in the grid. i.e. I am returning data in the SQL which I am not binding to the grid, but which I would like to read to enable me to make decisions on how to format specific values I am binding...if that makes sense.
Database Results
Product Category Price In Stock
I am not binding "In Stock" to a column in the grid - even though it is being returned inn the query, but want to check its value when the grid is bound so I can colour the Product field Red/Green.
Regards
I am using ItemDataBound now. The only problem is I need to access an element in the underlying row of data in the database, not in the grid. i.e. I am returning data in the SQL which I am not binding to the grid, but which I would like to read to enable me to make decisions on how to format specific values I am binding...if that makes sense.
Database Results
Product Category Price In Stock
I am not binding "In Stock" to a column in the grid - even though it is being returned inn the query, but want to check its value when the grid is bound so I can colour the Product field Red/Green.
Regards
0
Princy
Top achievements
Rank 2
answered on 24 Apr 2008, 09:30 AM
Hi Stephen,
Try the following code snippet in the PreRender event.
CS:
Thanks
Princy.
Try the following code snippet in the PreRender event.
CS:
| protected void RadGrid1_PreRender(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
| { |
| foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) |
| { |
| string strtxt = item[col.UniqueName].Text.ToString(); |
| if (strtxt == "Stephen") |
| { |
| item[col.UniqueName].BackColor = System.Drawing.Color.Red; |
| } |
| } |
| } |
| } |
Thanks
Princy.
0
Hi Stephen,
In this case, you would need to correlate the two pieces of information. For example, if each row contains some id, you can populate two tables - one for the grid, and one for the other info. both can contain the id, thus making it possible to compare the data. Or, even easier, you can include the data in the datsource for the grid, but simply not display it. This way, it would not be visible, but would still be accessible as data.
I hope these guidelines help.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
In this case, you would need to correlate the two pieces of information. For example, if each row contains some id, you can populate two tables - one for the grid, and one for the other info. both can contain the id, thus making it possible to compare the data. Or, even easier, you can include the data in the datsource for the grid, but simply not display it. This way, it would not be visible, but would still be accessible as data.
I hope these guidelines help.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Stephen
Top achievements
Rank 1
answered on 24 Apr 2008, 09:57 AM
Hi,
They are included in the datasource for the grid....they are not bound to any columns though. I assume ItemDataBound will only allow me to access elements as they are physically bound to a cell, so If I chosen not to bind Column X - how can I access it. This used to be possible in the ASP.NET Grid.
I could of course Add aBoundColumn to the data I need to use, and not display it....my question is if I choose not to display it...will the ItemDataBound get called for it - as it wont be rendered.
Regards
SM
They are included in the datasource for the grid....they are not bound to any columns though. I assume ItemDataBound will only allow me to access elements as they are physically bound to a cell, so If I chosen not to bind Column X - how can I access it. This used to be possible in the ASP.NET Grid.
I could of course Add aBoundColumn to the data I need to use, and not display it....my question is if I choose not to display it...will the ItemDataBound get called for it - as it wont be rendered.
Regards
SM
0
Hi Stephen,
Indeed, if you do not include the data as a source to a column, to which the column will be bound, the data will not be accessible. However, as I suggested previously, you can set a column to use the field in question, and simply set its Disabled property to false. In this way, the column will not be visible, but at the same time accessible for the needs of any calculations you may have.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Indeed, if you do not include the data as a source to a column, to which the column will be bound, the data will not be accessible. However, as I suggested previously, you can set a column to use the field in question, and simply set its Disabled property to false. In this way, the column will not be visible, but at the same time accessible for the needs of any calculations you may have.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Stephen
Top achievements
Rank 1
answered on 24 Apr 2008, 12:15 PM
Hi,
This doesnt make sense ;-)
Disabled property to false. This sounds like I want to "enable it"....how does disabling a bound column make it invisible...or do I also need to set the Visible property somehow?
Sorry...minds not working too well today
This doesnt make sense ;-)
Disabled property to false. This sounds like I want to "enable it"....how does disabling a bound column make it invisible...or do I also need to set the Visible property somehow?
Sorry...minds not working too well today
0
Hello Stephen,
Sorry for an omission on my part!
I actually meant the Display property, as shown in the code snippet below:
.aspx
I hope this helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Sorry for an omission on my part!
I actually meant the Display property, as shown in the code snippet below:
.aspx
| <rad:GridBoundColumn DataField="ShipName" |
| HeaderText="ShipName" SortExpression="ShipName" |
| UniqueName="ShipName" Display="false"> |
| </rad:GridBoundColumn> |
I hope this helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Stephen
Top achievements
Rank 1
answered on 24 Apr 2008, 12:48 PM
Thanks.