我有一个gridview,我添加了一个复选框列。为什么不复选框首次选择所有不适用于Firefox的?
随着复选框,选中所有,我使用jQuery
检查所有的复选框。
下面的代码是什么,我都试过了,
function checkBoxSelectAll() {
$("#chkSelectAll").click(function() {
$('input:checkbox').not(this).prop('checked', this.checked);
});
}
我使用的DevExpress GridView的在MVC5,这是我在查看代码
@(Html.DevExpress()
.GridView(settings =>
{
//settings.Settings.ShowVerticalScrollBar = true;
settings.Height = Unit.Percentage(100);
settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
settings.Settings.ShowFooter = true;
settings.Name = "gvw1";
settings.Width = Unit.Percentage(100);
settings.CallbackRouteValues = new
{
Controller = "Vehicle",
Action = "ListPartial"
};
settings.SettingsBehavior.AllowGroup = false;
settings.SettingsBehavior.AutoExpandAllGroups = true;
settings.KeyFieldName = "Id";
settings.Columns.Add("VehicleGroupName", Html.GetResource("group")).GroupIndex = 0;
settings.Columns.Add(column =>
{
column.SetHeaderTemplateContent(content =>
{
ViewContext.Writer.Write(string.Format("<input type='checkbox' name='chkSelectAll' id='chkSelectAll' onchange='checkBoxSelectAll()'/>"));
});
column.SetDataItemTemplateContent(c =>
{
ViewContext.Writer.Write(string.Format("<input type='checkbox' name='chkID' id='" + @c.KeyValue + "' />"));
});
});
的DevExpress GridView的生成以下HTML
<tr id="gvw1_DXDataRow1" class="dxgvDataRow_DevEx">
<td class="dxgvIndentCell dxgv" style="width:0px;border-left-width:0px;border-bottom-width:0px;"> </td>
<td id="gvw1_tccell1_1" class="dxgv" style="border-left-width:0px;">
<input type="checkbox" name="chkID" id="1657">
</td>
</tr>
它适用于Chrome,Safari,Opera,IE11,Microsoft Edge。 但在Firefox中,在第一次,它不起作用。 (当我点击复选框选择全部时,这个gridview中的所有复选框都没有选中)。 然后,我取消选中复选框全选,然后再次检查它,它工作,GridView中的所有复选框将被检查。
任何人都可以告诉我为什么?我正在使用jQuery 1.9.1
。
对不起,我的英语不好。
非常感谢,
张庭麦
添加您的完整代码,HTML和Javascript,也当'checkBoxSelectAll'被称为 – Tushar
'$( “#chkSelectAll”)。点击(函数(){'不必我认为....'function checkBoxSelectAll(){ var $ all = $(“#chkSelectAll”); $('input:checkbox')。not($ all).prop('checked',$ all [0] .checked); }' –
可以包含'html','js'在问题? – guest271314