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

Editable Checkbox in GridViewTemplate

2 Answers 194 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jako
Top achievements
Rank 1
Jako asked on 19 Feb 2016, 08:08 AM

Hi everyone. We have a child grid that is bound to data as requested. We have added a GridViewCheckBoxColumn to the row, but we can't seem to edit it?

Here we set the child element:

grdCustomers.DataSource = contact.GetList(true, 0);
grdCustomers.Templates.Add(CreateChildTemplate());
The CreateChildTemplate method looks like this:

private GridViewTemplate CreateChildTemplate()
{
    var template = new GridViewTemplate();
    template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    template.AllowEditRow = true;
    template.ReadOnly = false;           
 
    var select = new GridViewCheckBoxColumn("CheckBox");
    var field1 = new GridViewTextBoxColumn("Field1");
    var field2 = new GridViewTextBoxColumn("Field1");
    
    select.ReadOnly = false;
    select.DataType = typeof(bool);
    select.EditMode = EditMode.OnValueChange;           
     
    template.Columns.AddRange(select, field1, field2);
 
    return template;
}

Then we bind the data to the child grid

var row = e.Template.Rows.NewRow();
 
row.Cells["Field1"].Value = dataRow.Field1;
row.Cells["Field2"].Value = dataRow.Field2;
row.Cells["Select"].Value = dataRow.Select;
row.Cells["Select"].ReadOnly = false;
 
e.SourceCollection.Add(row);

No watter what we have tried, we can't get the checkbox to be editable?

Please advise.

Thank you.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Jako
Top achievements
Rank 1
answered on 19 Feb 2016, 08:28 AM

Sorry everyone, got it working. It was inheriting the parent grid's readonly setting.

0
Hristo
Telerik team
answered on 19 Feb 2016, 03:51 PM
Hi Jako,

Thank you for writing.

I am glad that you have resolved your issue.

Please let me know if you need additional information.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Jako
Top achievements
Rank 1
Answers by
Jako
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or