5 Answers, 1 is accepted
0
Hi Mark,
Once the grid is loaded you can iterate all rows and set the value. Then you will need to update it only when the other value is changed. Here is the code:
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Once the grid is loaded you can iterate all rows and set the value. Then you will need to update it only when the other value is changed. Here is the code:
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
foreach
(GridViewRowInfo row
in
radGridView1.Rows)
{
if
(row.Cells[
"Name"
].Value ==
null
|| row.Cells[
"Name"
].Value == DBNull.Value)
{
row.Cells[
"CheckBoxCol"
].Value =
false
;
}
else
{
row.Cells[
"CheckBoxCol"
].Value =
true
;
}
}
radGridView1.CellValueChanged += RadGridView1_CellValueChanged;
}
private
void
RadGridView1_CellValueChanged(
object
sender, GridViewCellEventArgs e)
{
if
(e.Column.Name ==
"Name"
)
{
if
(e.Value ==
null
|| e.Value == DBNull.Value)
{
e.Row.Cells[
"CheckBoxCol"
].Value =
false
;
}
else
{
e.Row.Cells[
"CheckBoxCol"
].Value =
true
;
}
}
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
.jpg)
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
answered on 30 Jan 2018, 02:11 PM
This is ok, but I am data binding the grid. I am then manually adding a checkboxgridcolumn after the binding and I want that check box to be checked if data in a field is not null and not empty.
0
Hello Mark,
You can change the "if' statement like this:
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
You can change the "if' statement like this:
if
(row.Cells[
"Name"
].Value !=
null
&& row.Cells[
"Name"
].Value.ToString() != String.Empty )
{
row.Cells[
"CheckBoxCol"
].Value =
false
;
}
else
{
row.Cells[
"CheckBoxCol"
].Value =
true
;
}
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
0
.jpg)
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
answered on 31 Jan 2018, 01:50 PM
So, i have to manually update each row's checkbox column when I load the data? I was hoping for something a little more automatic.
0
Hi Mark,
Another approach you can use is to create a custom function that checks for this and use it with expression column. Detailed information is available in the following articles:
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Another approach you can use is to create a custom function that checks for this and use it with expression column. Detailed information is available in the following articles:
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.