gridview 的 OnEditable 文本框在 Chrome 中不起作用
OnEditable textbox of gridview not working in Chrome
我已经从 here 中获取代码并在我的项目中实施,问题是它在 IE 中运行良好。但不处理 CHROME
这是我的代码:-
<cc1:Grid ID="GrdConfirmation" EnableTypeValidation="true" runat="server" Width="100%"
ShowFooter="false" AllowAddingRecords="true" AllowSorting="false" AutoGenerateColumns="false"
FolderStyle="../Styles/Grid/style_12">
<ClientSideEvents OnClientSelect="GrdConfirmation_OnClientSelect" />
<Columns>
<cc1:Column ID="Column1" DataField="MKEY" HeaderText="Select" ReadOnly="true" Width="3%"
runat="server">
<TemplateSettings TemplateId="gtchkConfirm" HeaderTemplateId="HTConfirm" />
</cc1:Column>
<cc1:Column ID="Sr_No" DataField="Sr_No" HeaderText="Sr No" Visible="false" Width="0%">
<TemplateSettings TemplateId="tplNumbering" />
</cc1:Column>
<cc1:Column ID="col_save_srno" DataField="save_srno" HeaderText="Sr.No" Visible="true"
Width="3%" Align="left">
</cc1:Column>
<cc1:Column ID="Line_Id" DataField="Line_Id" HeaderText="Line id" Visible="false"
Align="left" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Mkey" DataField="Item_Mkey" HeaderText="Item Mkey" Visible="false"
Align="center" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Code" DataField="Item_Code" HeaderText="Item Code" Visible="true"
Align="left" Width="5%">
</cc1:Column>
<cc1:Column ID="Item_Desc" DataField="Item_Desc" HeaderText="Item Description" Visible="true"
Align="left" Width="13%" Wrap="true" HeaderStyle-Wrap="true">
</cc1:Column>
<cc1:Column ID="Lot_Batch_No" DataField="Lot_Batch_No" HeaderText="Lot / Batch No."
Visible="true" Align="left" Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Exp_Dt" DataField="Exp_Dt" HeaderText="Exp Date" Visible="true" Align="left"
Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="QTY1" DataField="Qty" HeaderText=" Quantity" Visible="true" Width="6%"
Align="center">
</cc1:Column>
<cc1:Column ID="Bx_Bg" DataField="Bx_Bg" HeaderText="Boxes/Bags" Visible="true" Width="6%"
Align="center">
</cc1:Column>
<cc1:Column ID="Net_Wgt" DataField="Net_Wgt" HeaderText="Net Weight" Visible="true" HeaderAlign="center"
Width="6%" Align="center">
</cc1:Column>
<cc1:Column ID="NO_OF_PALLETS" DataField="NO_OF_PALLETS" HeaderText="No Of Pallets" HeaderAlign="center"
Visible="true" Align="center" Width="5%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Default_Allot" DataField="Default_Allot" HeaderText="Allocated Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Storage_type" DataField="Storage_type" HeaderText="Storage Type"
Visible="false" Width="0%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Damaged_Qty" DataField="Damaged_Qty" HeaderText="Damaged Qty in Units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Short_Fall_Excess" DataField="Short_Fall_Excess" HeaderText="Shortfall/ excess qty in units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
</Columns>
<Templates>
<cc1:GridTemplate runat="server" ID="PlainEditTemplate">
<Template>
<asp:TextBox runat="server" ID="txtconfirm" CssClass="excel-textbox" onfocus="markAsFocused(this)"
onblur="markAsBlured(this)" />
</Template>
</cc1:GridTemplate>
</Templates>
<AddEditDeleteSettings AddLinksPosition="Bottom" NewRecordPosition="Dynamic" />
<Templates>
<cc1:GridTemplate runat="server" ID="GridTemplate1">
<Template>
<input id="txttemp" type="text" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="HTConfirm">
<Template>
<input type="checkbox" onclick="toggleSelection(this)" id="ChkSelector" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="gtchkConfirm">
<Template>
<asp:CheckBox ID="chk_grid" runat="server" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="TextBoxEditTemplate">
<Template>
<input type="text" name="TextBox1111" id="Txtconfirm<%# (Container.RecordIndex) %>"
class="excel-textbox" readonly="readonly" onfocus="GrdConfirmation.editWithTextBox(this)" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="tplNumbering">
<Template>
<b>
<%# (Container.RecordIndex + 1)%>
</b>
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="TemplateWithCheckbox">
<Template>
<asp:CheckBox runat="server" ID="ChkID" ToolTip="<%# Container.Value %>" />
</Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>
这是我实现的相关javascript函数
function toggleSelection(checkbox) {
var con = confirm("Do you want check/unckeck all");
if (con == true) {
for (var ii = 0; ii < GrdConfirmation.getTotalNumberOfRecords(); ii++) {
var idt = "GrdConfirmation_ob_GrdConfirmationBodyContainer_ctl34_" + ii + "_ctl00_" + ii + "_txtconfirm_" + ii;
var idc = "GrdConfirmation_ob_GrdConfirmationBodyContainer_ctl02_" + ii + "_ctl00_" + ii + "_chk_grid_" + ii;
if (document.getElementById(checkbox.id).checked == true) {
document.getElementById(idt).value = GrdConfirmation.Rows[ii].Cells[13].Value;
// alert(GrdConfirmation.Rows[ii].Cells[13].Value);
document.getElementById(idc).checked = true;
}
else {
document.getElementById(idt).value = "";
document.getElementById(idc).checked = false;
}
}
}
}
我尝试在 Console
中调试我的代码,下面是出现的错误的屏幕截图。
错误是
Failed to load resource: the server responded with a status of 404 (Not Found)
经过这么多的研究,我终于得到了答案,
我刚刚添加了一个 属性 我想编辑文本框的地方
AllowEdit="true"
完整代码如下:-
<cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true" AllowEdit="true" >
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
我已经从 here 中获取代码并在我的项目中实施,问题是它在 IE 中运行良好。但不处理 CHROME
这是我的代码:-
<cc1:Grid ID="GrdConfirmation" EnableTypeValidation="true" runat="server" Width="100%"
ShowFooter="false" AllowAddingRecords="true" AllowSorting="false" AutoGenerateColumns="false"
FolderStyle="../Styles/Grid/style_12">
<ClientSideEvents OnClientSelect="GrdConfirmation_OnClientSelect" />
<Columns>
<cc1:Column ID="Column1" DataField="MKEY" HeaderText="Select" ReadOnly="true" Width="3%"
runat="server">
<TemplateSettings TemplateId="gtchkConfirm" HeaderTemplateId="HTConfirm" />
</cc1:Column>
<cc1:Column ID="Sr_No" DataField="Sr_No" HeaderText="Sr No" Visible="false" Width="0%">
<TemplateSettings TemplateId="tplNumbering" />
</cc1:Column>
<cc1:Column ID="col_save_srno" DataField="save_srno" HeaderText="Sr.No" Visible="true"
Width="3%" Align="left">
</cc1:Column>
<cc1:Column ID="Line_Id" DataField="Line_Id" HeaderText="Line id" Visible="false"
Align="left" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Mkey" DataField="Item_Mkey" HeaderText="Item Mkey" Visible="false"
Align="center" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Code" DataField="Item_Code" HeaderText="Item Code" Visible="true"
Align="left" Width="5%">
</cc1:Column>
<cc1:Column ID="Item_Desc" DataField="Item_Desc" HeaderText="Item Description" Visible="true"
Align="left" Width="13%" Wrap="true" HeaderStyle-Wrap="true">
</cc1:Column>
<cc1:Column ID="Lot_Batch_No" DataField="Lot_Batch_No" HeaderText="Lot / Batch No."
Visible="true" Align="left" Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Exp_Dt" DataField="Exp_Dt" HeaderText="Exp Date" Visible="true" Align="left"
Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="QTY1" DataField="Qty" HeaderText=" Quantity" Visible="true" Width="6%"
Align="center">
</cc1:Column>
<cc1:Column ID="Bx_Bg" DataField="Bx_Bg" HeaderText="Boxes/Bags" Visible="true" Width="6%"
Align="center">
</cc1:Column>
<cc1:Column ID="Net_Wgt" DataField="Net_Wgt" HeaderText="Net Weight" Visible="true" HeaderAlign="center"
Width="6%" Align="center">
</cc1:Column>
<cc1:Column ID="NO_OF_PALLETS" DataField="NO_OF_PALLETS" HeaderText="No Of Pallets" HeaderAlign="center"
Visible="true" Align="center" Width="5%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Default_Allot" DataField="Default_Allot" HeaderText="Allocated Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Storage_type" DataField="Storage_type" HeaderText="Storage Type"
Visible="false" Width="0%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Damaged_Qty" DataField="Damaged_Qty" HeaderText="Damaged Qty in Units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Short_Fall_Excess" DataField="Short_Fall_Excess" HeaderText="Shortfall/ excess qty in units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
</Columns>
<Templates>
<cc1:GridTemplate runat="server" ID="PlainEditTemplate">
<Template>
<asp:TextBox runat="server" ID="txtconfirm" CssClass="excel-textbox" onfocus="markAsFocused(this)"
onblur="markAsBlured(this)" />
</Template>
</cc1:GridTemplate>
</Templates>
<AddEditDeleteSettings AddLinksPosition="Bottom" NewRecordPosition="Dynamic" />
<Templates>
<cc1:GridTemplate runat="server" ID="GridTemplate1">
<Template>
<input id="txttemp" type="text" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="HTConfirm">
<Template>
<input type="checkbox" onclick="toggleSelection(this)" id="ChkSelector" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="gtchkConfirm">
<Template>
<asp:CheckBox ID="chk_grid" runat="server" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="TextBoxEditTemplate">
<Template>
<input type="text" name="TextBox1111" id="Txtconfirm<%# (Container.RecordIndex) %>"
class="excel-textbox" readonly="readonly" onfocus="GrdConfirmation.editWithTextBox(this)" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="tplNumbering">
<Template>
<b>
<%# (Container.RecordIndex + 1)%>
</b>
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="TemplateWithCheckbox">
<Template>
<asp:CheckBox runat="server" ID="ChkID" ToolTip="<%# Container.Value %>" />
</Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>
这是我实现的相关javascript函数
function toggleSelection(checkbox) {
var con = confirm("Do you want check/unckeck all");
if (con == true) {
for (var ii = 0; ii < GrdConfirmation.getTotalNumberOfRecords(); ii++) {
var idt = "GrdConfirmation_ob_GrdConfirmationBodyContainer_ctl34_" + ii + "_ctl00_" + ii + "_txtconfirm_" + ii;
var idc = "GrdConfirmation_ob_GrdConfirmationBodyContainer_ctl02_" + ii + "_ctl00_" + ii + "_chk_grid_" + ii;
if (document.getElementById(checkbox.id).checked == true) {
document.getElementById(idt).value = GrdConfirmation.Rows[ii].Cells[13].Value;
// alert(GrdConfirmation.Rows[ii].Cells[13].Value);
document.getElementById(idc).checked = true;
}
else {
document.getElementById(idt).value = "";
document.getElementById(idc).checked = false;
}
}
}
}
我尝试在 Console
中调试我的代码,下面是出现的错误的屏幕截图。
错误是
Failed to load resource: the server responded with a status of 404 (Not Found)
经过这么多的研究,我终于得到了答案,
我刚刚添加了一个 属性 我想编辑文本框的地方
AllowEdit="true"
完整代码如下:-
<cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true" AllowEdit="true" >
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>