Javascript 回邮时Jquery数据表分页不起作用
Jquery DataTable分页不起作用我有13个分页我正在选择第5个分页当我在gridview中单击编辑按钮时,页面将回发,分页不显示当前选择的(第5个)页面,它将直接显示到第1个页面。当我在回发后的分页中选择任何页面时,它也是如何显示当前所选页面的 我的代码是:Javascript 回邮时Jquery数据表分页不起作用,javascript,jquery,asp.net,datatables,Javascript,Jquery,Asp.net,Datatables,Jquery DataTable分页不起作用我有13个分页我正在选择第5个分页当我在gridview中单击编辑按钮时,页面将回发,分页不显示当前选择的(第5个)页面,它将直接显示到第1个页面。当我在回发后的分页中选择任何页面时,它也是如何显示当前所选页面的 我的代码是: <script type="text/javascript" src="DataTable/jquery-1.11.1.min.js"></script> <script type="tex
<script type="text/javascript" src="DataTable/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="DataTable/jquery.dataTables.min.js"></script>
<script>
$(function () {
// Setup - add a text input to each footer cell
$('#<%=GridView1.ClientID %> th').each(function () {
var title = $(this).text();
if (title == "A Name" || title == " Name" || title == "ttl") {
$(this).html(title + '<br/><input type="text" style="width:120px" placeholder="Search ' + title + '" />');
}
else {
if (title != " ") {
//$(this).html(title + '<br/><input type="text" style="background-color:#646464;border:none" disabled="disabled" />');
}
}
});
// DataTable
var table = $('#<%=GridView1.ClientID %>').DataTable({
"paging": true,
"ordering": false,
"info": false,
"pageLength": 10,
"bLengthChange": false
});
table.columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
} );
</script>
$(函数(){
//设置-向每个页脚单元格添加文本输入
$('#th')。每个(函数(){
var title=$(this.text();
if(title==“A Name”| | title==“Name”| | title==“ttl”){
$(this.html(title+'
');
}
否则{
如果(标题!=“”){
//$(this.html(title+'
');
}
}
});
//数据表
变量表=$('#')。数据表({
“分页”:正确,
“命令”:错误,
“信息”:错误,
“页面长度”:10,
“bLengthChange”:false
});
table.columns().every(函数(){
var=这个;
$('input',this.header()).on('keyup change',function(){
如果(that.search()!==this.value){
那个
.search(this.value)
.draw();
}
} );
} );
} );
和Gridview:
<asp:GridView ID="GridView1" runat="server" Width="100%" CssClass="mydatagrid" HeaderStyle-CssClass="header" RowStyle-CssClass="rows" AutoGenerateColumns="false"
EmptyDataText="No files uploaded" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
<columns>
Some Columns
</columns>
</asp:gridview>
谁能告诉我
谢谢没有看到服务器端或代码隐藏文件,我不能肯定您的问题就在这里
如果您正在页面加载事件中加载初始网格和值,则可能值得检查IsPostBack
您的页面加载
应该如下所示:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//page is being loaded in response to a client postback, so do not load initial values again
//Do your initial loading of grid here
YourPopulateGridMethod();
}
}
如果没有看到您的服务器端或文件背后的代码,我不能肯定您的问题就在这里
如果您正在页面加载事件中加载初始网格和值,则可能值得检查IsPostBack
您的页面加载
应该如下所示:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//page is being loaded in response to a client postback, so do not load initial values again
//Do your initial loading of grid here
YourPopulateGridMethod();
}
}
显示服务器端代码,代码隐藏文件。您是否正在“页面加载”中加载任何数据?如果是,请检查表单加载事件中是否存在IsPostBack。显示服务器端代码,即代码隐藏文件。您是否正在“页面加载”中加载任何数据?如果是这样,请在表单加载事件中检查IsPostBack。您好,@monstertjie za,我已尝试使用您的代码。当我使用Jquery Datatable插件时,分页回发我的页面将不会显示当前页面。这里我使用Jquery Datatable分页显示OnRowDataBound事件。在OnRowDataBound事件中,我只是设置gridview样式,foreach(e.Row.Cells中的System.Web.UI.WebControls.TableCell tc){tc.BorderStyle=BorderStyle.None;tc.BorderWidth=0;tc.BorderColor=System.Drawing.Color.Transparent;}
Hi,@monstertjie za,我尝试了你的代码。当我使用Jquery Datatable插件时,分页回发我的页面不会显示当前页面。这里我使用Jquery Datatable分页显示OnRowDataBound事件。在OnRowDataBound事件中,我只是设置gridview样式,foreach(e.Row.Cells中的System.Web.UI.WebControls.TableCell tc){tc.BorderStyle=BorderStyle.None;tc.BorderWidth=0;tc.BorderColor=System.Drawing.Color.Transparent;}