我在GridView中使用了响应式DataTable类。在GridView的EditItemTemplate上禁用排序
<asp:GridView ID="myGrid" runat="server" EnableViewState="False"
CssClass="table table-striped table-bordered table-hover">
<Columns>
<asp:CommandField ShowEditButton="true" CausesValidation="true" />
使用下面的脚本:
<script>
$(document).ready(function() {
$("#<%= myGrid.ClientID %>").DataTable({
responsive: true,
"columnDefs": [{ "orderable": false, "targets": ['_all'] }],
});
});
</script>
这个脚本禁用所有列排序选项除了我的第一列,其中有正在使用的GridView的ShowEditButton="true"
启用编辑按钮。
我可以在页面看到呈现的HTML,第一列仍然有class="sorting_asc"
,而其他所有列都有class="sorting_disabled"
。如何禁用GridView为Edit/Update/Cancel添加的列进行排序?
我尝试过'{“orderable”:false,“targets”:['_all']}',它根本不禁止排序。每个列出现的箭头尽管如此 – techspider
我更新了帖子 – levent
我不想单独控制每个列,我想禁用所有列的排序。除了用CommandField添加的列以外,它将禁用我的脚本。 – techspider