Skip to main content

asp.net mvc 3 - Make the MVCContrib-generated-column-names to make ajax calls -


it sounds simple question, i've been strugling entire afternoon. i'm trying put grid in partialview pagination, sorting , everything. first problem pager links: did not hold filter options, since not on pages query string. that's how solved it:

public class paginationcontainer { public ipagination paginatedresult { get; set; } public routevaluedictionary routevaluedictionary { get; set; } } 

i created class, used pager:

@using mvccontrib.ui.pager @model aqxweb.models.paginationcontainer @{ string action = viewcontext.controller.valueprovider.getvalue("action").rawvalue.tostring(); string controller = viewcontext.controller.valueprovider.getvalue("controller").rawvalue.tostring(); } @functions { public routevaluedictionary getroute(int page) { var routevalues = new routevaluedictionary(); foreach (string key in model.routevaluedictionary.keys) { routevalues[key] = model.routevaluedictionary[key]; } routevalues["page"] = page; return routevalues; } } <p /> <div class='pagination'> <span class='paginationleft'>mostrando @model.paginatedresult.firstitem - @model.paginatedresult.lastitem de @model.paginatedresult.totalitems</span> <span class='paginationright'> @{ if (model.paginatedresult.haspreviouspage) {<text> @html.actionlink("primeira", action, controller, getroute(1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text> primeira | </text>} if (model.paginatedresult.haspreviouspage) {<text>@html.actionlink("anterior", action, controller, getroute(model.paginatedresult.pagenumber - 1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text>anterior | </text>} if (model.paginatedresult.hasnextpage) {<text>@html.actionlink("próxima", action, controller, getroute(model.paginatedresult.pagenumber + 1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text>próxima | </text>} if (model.paginatedresult.hasnextpage) {<text>@html.actionlink("Última", action, controller, getroute(model.paginatedresult.totalpages), new dictionary<string, object> { { "class", "paging" } })</text>} else {<text>Última</text>} } </span> </div> 

all have fill dictionary, on actionmethod.

now need similar solution sorting ... need override table headers created mvccontrib add filter options , add class attribute called "paging", use make ajax calls. exposed method .header(string) igridcolumn<>, and, honestly, sucks (i'll have stuff hand in order achieve goal). trying create extension method cope this, proved quite difficult, since .header(string) not exposed:

(please overlook bad naming)

public static igridcolumn<t> ajaxify(this igridcolumn<t> column, string columnname, string classname, routevaluedictionary routevaluedictionary) { string newdecoration = "<td> <a href="+getroute(routevaluedictionary)+"class=\""+classname+"\">"+ columnname + "</a></td>"; return column.header(newdecoration); } 

i think intention here quite clean, method wouldn't work, because somehow can't access .header(string) method. ideas?

asp.net mvc 3 - make mvccontrib-generated-column-names make ajax calls - stack overflow

learn, share, build

each month, on 50 million developers come stack overflow learn, share knowledge, , build careers.

join world’s largest developer community.

sign up

it sounds simple question, i've been strugling entire afternoon. i'm trying put grid in partialview pagination, sorting , everything. first problem pager links: did not hold filter options, since not on pages query string. that's how solved it:

public class paginationcontainer { public ipagination paginatedresult { get; set; } public routevaluedictionary routevaluedictionary { get; set; } } 

i created class, used pager:

@using mvccontrib.ui.pager @model aqxweb.models.paginationcontainer @{ string action = viewcontext.controller.valueprovider.getvalue("action").rawvalue.tostring(); string controller = viewcontext.controller.valueprovider.getvalue("controller").rawvalue.tostring(); } @functions { public routevaluedictionary getroute(int page) { var routevalues = new routevaluedictionary(); foreach (string key in model.routevaluedictionary.keys) { routevalues[key] = model.routevaluedictionary[key]; } routevalues["page"] = page; return routevalues; } } <p /> <div class='pagination'> <span class='paginationleft'>mostrando @model.paginatedresult.firstitem - @model.paginatedresult.lastitem de @model.paginatedresult.totalitems</span> <span class='paginationright'> @{ if (model.paginatedresult.haspreviouspage) {<text> @html.actionlink("primeira", action, controller, getroute(1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text> primeira | </text>} if (model.paginatedresult.haspreviouspage) {<text>@html.actionlink("anterior", action, controller, getroute(model.paginatedresult.pagenumber - 1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text>anterior | </text>} if (model.paginatedresult.hasnextpage) {<text>@html.actionlink("prã³xima", action, controller, getroute(model.paginatedresult.pagenumber + 1), new dictionary<string, object> { { "class", "paging" } }) | </text>} else {<text>prã³xima | </text>} if (model.paginatedresult.hasnextpage) {<text>@html.actionlink("ãšltima", action, controller, getroute(model.paginatedresult.totalpages), new dictionary<string, object> { { "class", "paging" } })</text>} else {<text>ãšltima</text>} } </span> </div> 

all have fill dictionary, on actionmethod.

now need similar solution sorting ... need override table headers created mvccontrib add filter options , add class attribute called "paging", use make ajax calls. exposed method .header(string) igridcolumn<>, and, honestly, sucks (i'll have stuff hand in order achieve goal). trying create extension method cope this, proved quite difficult, since .header(string) not exposed:

(please overlook bad naming)

public static igridcolumn<t> ajaxify(this igridcolumn<t> column, string columnname, string classname, routevaluedictionary routevaluedictionary) { string newdecoration = "<td> <a href="+getroute(routevaluedictionary)+"class=\""+classname+"\">"+ columnname + "</a></td>"; return column.header(newdecoration); } 

i think intention here quite clean, method wouldn't work, because somehow can't access .header(string) method. ideas?

share|improve question

your answer

 
discard

posting answer, agree privacy policy , terms of service.

browse other questions tagged or ask own question.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -