I have a boolean value in a datatable that i bind to a datagrid from the codebehind. But instead of a checkbox the webDataGrid displays "true" or "false" and that column is editable like a string value.
Here is some code that i'm using (_sestevalniDT is a DataTable and SestevalniStevec is a WebDataGrid):
_sestevalniDT = new DataTable();
_sestevalniDT.Columns.Add(new DataColumn("Naziv", typeof(string)));
_sestevalniDT.Columns.Add(new DataColumn("Popravek", typeof(bool)));
...SestevalniStevec.DataSource = _sestevalniDT;
SestevalniStevec.DataBind();
and this is from my aspx:
<ig:WebDataGrid ID="SestevalniStevec" runat="server" StyleSetName="Appletini" Width="640" Height="480" DataKeyFields="Naziv"> <Behaviors> <ig:ColumnResizing Enabled="true"> <ColumnSettings> <ig:ColumnResizeSetting EnableResize="true" /> </ColumnSettings> </ig:ColumnResizing> <ig:EditingCore> <Behaviors> <ig:CellEditing Enabled="true" EditModeActions-MouseClick="Single"> <CellEditingClientEvents EnteringEditMode="svoEnteringEditMode" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid>
What should i add in order for the bool value to display as a checkbox?
Thanks for your help.
Did you have any luck with this? I need to do the same and I'm quite disappointed with Infragistics... It's just a simple checkbox, how could it be so hard!?!
I just noticed that the RowEditingTemplate seems to be something completely different from what i need, so i'm back to trying what i described on 06-07-2010 7:10 AM.
Can somebody please help me make it work?
Ok, i think i figured out where to put it, but it still doesn't display the Popravek column as a checkbox, does anybody see any obvious errors?
<Columns> <ig:BoundDataField Key="Naziv"> <Header Text="Naziv" /> </ig:BoundDataField> <ig:BoundDataField Key="Odčitek"> <Header Text="Odčitek" /> </ig:BoundDataField> <ig:BoundDataField key="Popravek"> <Header Text="Popravek" /> </ig:BoundDataField> <ig:BoundDataField Key="Količina"> <Header Text="Količina" /> </ig:BoundDataField> <ig:BoundDataField Key="Preračun"> <Header Text="Preračun" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:ColumnResizing Enabled="true"> <ColumnSettings> <ig:ColumnResizeSetting EnableResize="true" /> </ColumnSettings> </ig:ColumnResizing> <ig:EditingCore> <Behaviors> <ig:CellEditing Enabled="true" EditModeActions-MouseClick="Single"> <CellEditingClientEvents EnteringEditMode="svoEnteringEditMode" /> <EditModeActions MouseClick="Single" /> </ig:CellEditing> <ig:RowEditingTemplate> <ClientBindings> <ig:RowEditingClientBinding ColumnKey="Popravek" ControlID="popravek_IsActive" GetValueJavaScript="$get({ClientID}).checked" SetValueJavaScript="$get({ClientID}).checked={value}" /> </ClientBindings> <Template> <asp:CheckBox ID="popravek_IsActive" runat="server" /> </Template> </ig:RowEditingTemplate> </Behaviors> </ig:EditingCore> </Behaviors>
Everything i tried so far didn't work, bur this looks promising:
http://community.infragistics.com/forums/p/38015/219382.aspx
However that post doesn't mention where in the aspx i need to put the RowEditingClientBinding element, everywhere i tried to put it, i got an error. Does anybody know where it belongs?
Now i managed to get the checkbox to update the value in the webdatagrid, but when i click my store button the changes don't get stored in my datasource.In the image you can see that the Popravek value changes with the checkbox, but the actual value in the datasource stays the same.
Any suggestions about how i could make it work?
This is my javascript function at the moment:
function boxClicked(checkbox) { var cbid = checkbox.id; var cblen=cbid.length var idnum = parseInt(cbid.substring(cblen - 2, cblen)); var ssgrid = $find('<%= SestevalniStevec.ClientID %>'); var row = ssgrid.get_rows().get_row(idnum); var cell = row.get_cellByColumnKey("Popravek"); var element = cell.get_element(); element.firstChild.data = checkbox.checked; }