DevExpress Batch Edit Grid
The ASPxGridView control allows modify grid data on the client side and then send it to the server. All user changes are maintained on the client side until a user clicks the SaveChange or Cancel button. Set the ASPxGridViewEditingSettings.Mode property to Batch to enable the batch edit functionality. In this article we discuss how to Select All Check Box in DevExpress Batch Edit Grid
DevExpress GridView Partial
@{
var grid = Html.DevExpress().GridView(settings =>
{
settings.Name = "gvName";
settings.SettingsEditing.Mode = GridViewEditingMode.Batch;
settings.CommandColumn.Visible = true;
settings.SettingsEditing.BatchEditSettings.ShowConfirmOnLosingChanges = true;
settings.SettingsEditing.BatchEditSettings.EditMode = GridViewBatchEditMode.Row;
settings.KeyFieldName = "varKeyCol";
settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
settings.CommandColumn.SetHeaderTemplateContent(c =>
{
Html.DevExpress().CheckBox(settingsCheckBox =>
{
settingsCheckBox.Name = "cbSelectAll";
settingsCheckBox.Text = "Select All";
settingsCheckBox.Properties.ClientSideEvents.CheckedChanged =
string.Format("function(s, e) {{ gvSelectAll('{0}'); }}",
settingsCheckBox.Checked).ToString();
settingsCheckBox.Properties.ClientInstanceName = "cbSelectAll";
}).Render();
});
settings.Columns.Add(col =>
{
col.FieldName = "bitIsCheck";
col.ColumnType = MVCxGridViewColumnType.CheckBox;
varckProperties = col.PropertiesEdit asCheckBoxProperties;
ckProperties.ClientInstanceName = "bitIsCheck";
});
settings.Columns.Add(col =>
{
col.FieldName = "ColName";
col.Caption = "Col Name";
col.ReadOnly = true;
});
});
if (ViewData["EditError"] != null)
{
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
@grid.Bind(Model).GetHtml()
JavaScript
function gvSelectAll() {
bitCheck = cbSelectAll.GetChecked();
var mRow = gvName.GetVisibleRowsOnPage();
for (i = 0; i < mRow; i++) {
gvName.StartEditRow(i);
gvName.GetEditor("bitIsCheck").SetValue(bitCheck);
}
}
Select All Check Box in DevExpress Batch Edit Grid : Free Guide