如何在webgrid中分页后保留隐藏字段值 [英] How do I retain the hidden field value after the pagination in webgrid

查看:69
本文介绍了如何在webgrid中分页后保留隐藏字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在我的MVC项目中使用网格分页



我还将值保存在一个隐藏字段中,



问题当我点击网格中的下一页链接时,隐藏字段值会丢失,所以请帮我解决此问题。



提前感谢,

velsamy



我的尝试:



i已在谷歌搜索,没有得到任何东西

Hi all,

I am using the web grid with pagination in my MVC project.

also i maintaining the value in one hidden field,

the problem is while i click the next page link in web grid the hidden field values are lost, so help me to resolve this issue.

thanks in advance,
velsamy

What I have tried:

i have searched in google , didnt get anything

推荐答案

寻呼机链接生成 GET 请求。它不会从您的表单中传递任何其他字段。



要解决此问题,您需要使用Javascript截取页面链接上的click事件,并且提交表格。 此StackOverflow答案 [ ^ ]描述如何:

The pager link makes a GET request. It does not pass across any other fields from your form.

To resolve this, you'll need to use Javascript to intercept the click event on the page links, and submit the form instead. This StackOverflow answer[^] describes how:
@Html.HiddenFor(x => x.Page, new { id = "page" })





function (){


' tfoot a')。click( function (){
// 当用户点击任何寻呼机链接时
// 尝试提取链接中的页码和
// 设置隐藏字段的值
var page = this .href.match(/ page =([0-9])+ /)[ 1 ];
('tfoot a').click(function () { // when the user clicks on any of the pager links // try to extract the page number from the link and // set the value of the hidden field var page = this.href.match(/page=([0-9])+/)[1];


这篇关于如何在webgrid中分页后保留隐藏字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆