Hello
I have a BoundCheckBoxField in my WebDataGrid; How to added a checkBox in WebDataGrid header's to select all rows ?
BoundCheckBoxField ckbField = new BoundCheckBoxField(true);
ckbField.Key =
ckbField.DataFieldName =
ckbField.DataType =
WebDataGrid1.Columns.Add(boundField);
Hi gtarek,
The BoundCheckBoxField currently does not feature a header checkbox functionality.
You should be able to use an UnboundCheckBoxField (which has a header checkbox) to fulfil your requirements: the value of the field can be set in the InitializeRow event based on your datasource values. Grid cell updates in this case would need to be handled manually if you need to update your datasource.
Please tell me if this helps.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Hi Petar,
I found many difficulties to update may datasource when WebDataGrid's rows are selected after Paging or Filtering.
It is possible to add a CheckBox (Not necessarily in WebDataGrid Header) to select all BoundCheckBoxFields at client side ?
Thanks for your help
I have created a sample for you with a WebDataGrid which uses a templated checkbox for the BoundCheckBoxField header. The header checkbox's OnChange client side event is handled in order to iterate through the grid rows and set the state for each checkbox cell.
Below is the javascript function used:
function checkedChangedHandler() { //variable to hold the status of the checkBox. The tricky part is to access the input element. var checkBoxState = ig_controls.WebDataGrid1.get_columns().get_column(2).get_headerElement().children[0].children[0].checked; //iterate through the rows and set the checkBox states and cell values for (i = 0; i < ig_controls.WebDataGrid1.get_rows().get_length(); i++) { ig_controls.WebDataGrid1.get_rows().get_row(i).get_cell(2)._setCheckState(checkBoxState); ig_controls.WebDataGrid1.get_rows().get_row(i).get_cell(2).set_value(checkBoxState); } }
Here is the relevant markup for the WebDataGrid:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Height="350px" Width="400px"> <Columns> <ig:BoundDataField DataFieldName="ProductID" Key="ProductID"> <Header Text="ProductID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ProductName" Key="ProductName"> <Header Text="ProductName" /> </ig:BoundDataField> <ig:BoundCheckBoxField DataFieldName="Discontinued" Key="Discontinued"> <Header TemplateId="HeaderTemplate" Text="Discontinued" /> </ig:BoundCheckBoxField> </Columns> <Templates> <ig:ItemTemplate ID="WebDataGrid1Template1" runat="server" TemplateID="HeaderTemplate"> <Template> <asp:CheckBox ID="CheckBox1" runat="server" onchange="checkedChangedHandler();" /> </Template> </ig:ItemTemplate> </Templates> </ig:WebDataGrid>
Please let me know if this helps.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
As an alternative to what Petar provided earlier in this thread, you can accomplish this without using a template by putting a html input in the Header Text:
<ig:BoundCheckBoxField DataFieldName="OnSite" Key="OnSite"> <Header Text="On Site <input type='checkbox' onchange='headerCheckedChangedHandler(this);'"></Header></ig:BoundCheckBoxField>
Note that I also modified the onchange handler so that it can be used for multiple columns in the same grid:
function headerCheckedChangedHandler(checkbox) { var grid = $find("WebDataGrid1"); var checkBoxState = checkbox.checked; var columnKey = checkbox.parentElement.getAttribute("key"); var rows = grid.get_rows(); // iterate through the rows and set the checkBox states and cell values for (i = 0; i < rows.get_length() ; i++) { var cell = rows.get_row(i).get_cellByColumnKey(columnKey); cell._setCheckState(checkBoxState); cell.set_value(checkBoxState); }}
Hi,
I am also getting same problem in IE8 and Chrome. IE9 above give script working fine. Please tell me any suggestion for working in IE8 and Chrome.
Hi all,
Please let me know if you need more help with this matter.
Hi Sameem
Try to use onClick event
onClick="BLOCKED SCRIPTcheckedChangedHandler()"
Hi,Some how the onchange="checkedChangedHandler();" event is not firing for me?Can you help?
ThanksSameem