Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
How can I get RowAdding to work with BoundCheckBoxField?
posted

Hello!

 

In my DataSource, there is a boolean property that I'm representing via a BoundCheckBoxField in my grid (whick works fine). CellEditing with the CheckBox also works, but I want to be using RowAdding, and I just can't get it work with BoundCheckBoxField at all. I can see the CheckBox in the AddNewRow but can't enter the cell, but manually setting ReadOnly to false for the Editing doesn't change it either. If I switch to BoundDataField with DataType="System.Boolean" it's working again, but I lack the nice CheckBoxes. Here is a minimal example:

 

<asp:ScriptManager runat="server" />

<ig:WebDataGrid ID="WebDataGrid1"   runat="server"   AutoGenerateColumns="False"   EnableAjax="False"   DataKeyFields="ID"   Height="350px"   Width="400px"   DataSourceID="source">

<Columns>

<ig:BoundDataField Key="Name" DataFieldName="Name" Header-Text="Name" />

<ig:BoundCheckBoxField Key="Female" DataFieldName="IsFemale" Header-Text="Female?" />

<ig:BoundDataField Key="Birthday" DataFieldName="Birthday" Header-Text="Birthday" DataType="System.DateTime" />

</Columns> <Behaviors>

<ig:EditingCore Enabled="true" BatchUpdating="true">

<Behaviors>

<ig:RowAdding Alignment="Top" Enabled="true" />

<ig:CellEditing Enabled="true" />

</Behaviors>

</ig:EditingCore>

</Behaviors>

</ig:WebDataGrid>

<asp:ObjectDataSource ID="source" TypeName="WebApplication2.Source" SelectMethod="GetData" runat="server" />  

 

The code for the DataSource is:

 

namespace WebApplication2

{

public class Source

{

public IList GetData()

{

 return new List<Person>() { new Person { ID = 1, Birthday = DateTime.Now, Name = "Me", IsFemale = false } };

}

}

 public class Person

{

public int ID { get; set; }

public DateTime Birthday { get; set; }

public string Name { get; set; }

public bool IsFemale { get; set; } } }

 

Thanks in advance for any help getting this to work (if it's possible) with CheckBoxes!

 

PS: This time I decided to use CellEditing, but when I tried RowEditing, as soon as I enter a row with a BoundCheckBoxField inside, the state of the CheckBox is not saved (it's always Unchecked when in RowEditing mode, but reverts to its initial state on "Done" if I didn't touch it).

  • 49378
    posted

    Hello Johannes,

    I have tested this scenario but so far couldn't find any issues with checking the adding row checkbox in WebDataGrid. More information on the exact version used in your scenario would be appreciated.

    Please note that the Editing Core requires the Activation behavior to be enabled in order to function correctly. In addition, note that an IList datasource requires handling updates manually:

    http://help.infragistics.com/doc/ASPNET/2014.1/CLR4.0/?page=WebDataGrid_Supported_Data_Sources.html

    Attached is my test sample for your reference.

    Please do not hesitate to contact me with any updates or questions.

    WebDataGridEditBoundCheckboxField.zip
  • 360
    posted

    This is not an answer, but as soon as I click Edit on the above post, the HTML source code disappears in the editor and the preview, so I rather replied here instead.

     

    As a small update: The CellEditing behavior is not as correct as I thought. If the boolean property of the underlying data is already "true" (e.g. set IsFemale to true in the above code), then I can't uncheck the Checkbox. And that is consistently so: I can check unchecked CheckBoxes (and uncheck them again), but I cannot uncheck checked CheckBoxes at all, even if they all are in the same editable/non-readonly column.