webgrid

MVC 4 WebGrid and Jquery produces two errors. JQuery is undefined and a sort error after ajax model change

99封情书 提交于 2019-12-12 15:26:09
问题 Inside my div element I am updating is a page partial with a webgrid and when I specifiy ajaxUpdateContainerId: in the webgrid constructor I get the error: JavaScript runtime error: 'jQuery' is undefined Here is the generated javascript the error references: <script type="text/javascript"> (function($) { $.fn.swhgLoad = function(url, containerId, callback) { url = url + (url.indexOf('?') == -1 ? '?' : '&') + '__swhg=' + new Date().getTime(); $('<div/>').load(url + ' ' + containerId, function

How to change WebGrid action for getting data (.NET MVC3)

不想你离开。 提交于 2019-12-12 07:36:41
问题 I have a Partial View that renders WebGrid. My controller looks like public ActionResult Index() { return View(); } public ActionResult GetUserList(int? page, string sort, string sortdir) { var model = UserModel.getList(page,sort,sortdir); return PartialView("_UserList",model); } Index.cshtml : .... @Html.Action("GetUserList") The problem is that every time I click on grid navigation or sort links it calls Index method. How can I make Webgrid to execute a different action ( GetUserList in

Ajax.Actionlink, partial and webgrid issue

≯℡__Kan透↙ 提交于 2019-12-12 05:58:26
问题 I have the following issue. My url structure is like this: /people/edit/usercode In my controller i have the following: [AcceptVerbs(HttpVerbs.Post)] public PartialViewResult LoanRefresh(string id) { PeopleModel p = new PeopleModel(); return PartialView("_LoanHistory", p.getPersonLoanHistory(id)); } In my view i have: @Ajax.ActionLink("Refresh", "LoanRefresh", new { id = Model.IdentityCode }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "loanHistory", LoadingElementId = "Loading" }

How to get an object from the webgrid.

人盡茶涼 提交于 2019-12-12 04:53:08
问题 I've got a MVC webgrid which i'm populating with user objects. @model IEnumerable<UserSearchDisplayModel> <div class="user-search-list"> @{ var grid = new WebGrid(Model, defaultSort: "UserName", rowsPerPage: 25, selectionFieldName:"SelectedRow"); } @grid.GetHtml( tableStyle: "webgrid-table", headerStyle: "webgrid-header", footerStyle: "webgrid-footer", alternatingRowStyle: "webgrid-alternating-row", selectedRowStyle: "webgrid-selected-row", rowStyle: "webgrid-row-style", mode:

Present multiple IEnumberables and single value properties in single webgrid

无人久伴 提交于 2019-12-12 03:57:11
问题 I have an Inventory Class that contains not only its own fields but several reference IDs to other classes. public class Inventory { public int Id { get; set; } public string RtNum { get; set; } public string AcntNum { get; set; } public string CardNum { get; set; } public string Num { get; set; } [Range(1,3)] public int Type { get; set; } public int CompanyId { get; set; } public int BranchId { get; set; } public int PersonId { get; set; } } In my action I generate several IEnumerable lists

MVC 3 WebGrid Paging doesn't return orginal search results

孤街醉人 提交于 2019-12-12 02:53:55
问题 I have a search page with which on load fills a webgrid. My issue is with paging. On load I fill the grid with "Non published" articles (there are none in this case). Then I search for "Currently Published) and get 3 rows. Now I have 3 pages (I set paging to one row per page for testing purposes). The first time it searches - it gets the right answers in the grid,a nd lets say there are 2 pages. If I click the 2 to go to the second page - the grid fills with the criteria of the load - which

How to put empty strings at the end when sorting

时光毁灭记忆、已成空白 提交于 2019-12-11 19:48:35
问题 When sorting a column on my WebGrid from A to Z, the empty strings always come up first, so I have : "" "" "A" "B" (Without the quotes of course). I want them to come up last, is there a simple way to do this ? 回答1: you should sort with generic Comparison delegate like this one: private int MyComparison(string x, string y) { if (string.IsNullOrEmpty(x)) { if (string.IsNullOrEmpty(y)) { // If x is null and y is null, they're // equal. return 0; } else { // If x is null and y is not null, y //

I just want to style the current page or selected page in a WebGrid, How do i do it?

自古美人都是妖i 提交于 2019-12-11 18:28:53
问题 How to highlight the current page number in MVC WebGrid This is my webgrid control @{ var grid = new WebGrid(canPage: true, rowsPerPage: @Model.PageSize, canSort: true, ajaxUpdateCallback: "getStars", ajaxUpdateContainerId: "suppListGrid"); grid.Bind(@Model.SearchResultSupplierViewModels, rowCount: @Model.TotalPageRows, autoSortAndPage: false); grid.Pager(WebGridPagerModes.All); @grid.GetHtml(tableStyle: "webGrid", footerStyle:"pp-pagenumber", htmlAttributes: new {id="suppListGrid"}, columns:

WebGrid: cannot convert from 'lambda expression' to 'System.Func<dynamic,object>'

大憨熊 提交于 2019-12-11 10:42:02
问题 I am trying to handle a case of a DateTime which might be null when rendering in a ASP.NET MVC3 WinGrid. I am getting an error when trying to set the WebGridColumn. I have one that I got working, one that isn't. The one that is working is less idea, for the html is generated within the helper function. What I cannot figure out is why the ideal one isn't working. Here is the one that works: $gridSummary.Column("OngoingDate", header: "Ongoing", format: Html.DateTimeActionLink, style:

Default Sort is not working while using WebGrid Helper With Column as hidden

 ̄綄美尐妖づ 提交于 2019-12-11 10:39:13
问题 I am using @grid.GetHtml gridview to show the grid in my ASP.NET MVC4 application. Default Sort is not working while using WebGrid Helper With Column (Primary Key) as hidden. Using SP to fetch the web grid data and also default sort is given in SP. My code: @grid.GetHtml( htmlAttributes: new { id = "XXXX" }, tableStyle: "table table-bordered table-condensed table-hover table-striped", headerStyle: "info", footerStyle: "webgrid-footer", alternatingRowStyle: "webgrid-alternating-row",