我在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