Webgrid MVC中的排序和分页问题 [英] Sorting and Paging Issue in Webgrid MVC

查看:70
本文介绍了Webgrid MVC中的排序和分页问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webgrid排序网址中遇到一个奇怪的问题。



首次加载时,它会使用ActionName的url进行渲染。假设url是// hostname / mysite / GetAction,那么webgrid将排序url呈现为​​// hostname / mysite / GetAction?sort = col1& sortdir = ASC



所以非常好。



但是当我点击对webgrid中的一个列进行排序时,问题就出现了,它会变为不同的URL。它使用Form的动作url呈现在HTML下。



或者我执行了不同的Action然后href为所有锚点改变了分页和排序。

I am facing a strange issue in webgrid sorting url.

On first load it renders with url of ActionName. Say if url is //hostname/mysite/GetAction then webgrid renders the sorting url as //hostname/mysite/GetAction?sort=col1&sortdir=ASC

So far so good.

But problem arises when i click to sort one of the column on webgrid it changes to different url. It renders with action url of the Form under which it is placed in HTML.

Or i executed different Action then href for all anchor like paging and sorting is changed.

推荐答案

I was also facing the same issue like lost of original URL for Sorting and paging for WebGrid Control in MVC.I did some custom solution.

Please find it here .This is in JQuery.Please let me know for any query.

For first time on page load i am Storing Original URL in Hidden.


function SetHref()
{


' #checkableGrid')。find(' a' ).each(function(){
var URL = this .href.split(< span class =code-string>' ?')[ 0 ]
var hiddenhrefval =
('#checkableGrid').find('a').each(function () { var URL = this.href.split('?')[0] var hiddenhrefval =


#hiddenhref)。val();
if (URL!= && URL!= undefined)
{
if (hiddenhrefval == ){
("#hiddenhref").val(); if(URL != "" && URL != undefined) { if (hiddenhrefval == "") {


这篇关于Webgrid MVC中的排序和分页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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