Editable Checkbox in GridViewTemplate

3 posts, 0 answers
  1. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 19 Feb Link to this post

    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. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 19 Feb in reply to Jako Link to this post

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

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 19 Feb Link to this post

    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
Back to Top