webgrid

MVC WebGrid - How to programatically get the current page, sort column etc

*爱你&永不变心* 提交于 2020-01-01 16:06:12
问题 How can I programatically (in javascript) get the current page number, last sort column and sort direction of the ASP.NET MVC WebGrid? Is it possible to update the arguments before it calls the $("#grid").load() method? 回答1: The only possible solution was to use jQuery to retrieve: - the "href" attribute from the first column header to get the page number and - the "href" attribute from the "next page number" to get the sort column and sort directions. function reloadGrid(form) { var grid =

ASP.NET MVC3 WebGrid - custom, server-side sorting

穿精又带淫゛_ 提交于 2019-12-29 08:53:09
问题 Is there a way to override default MVC3 WebGrid sorting behavior to call my controller (which will perform server side sorting and return the data) when sort is called? Thanks for any help! 回答1: You can pass the server side sorted data to the webgrid, along with the info on how many records there are. http://msdn.microsoft.com/en-us/magazine/hh288075.aspx has a helpful walkthrough. I'm doing database level sorting/filtering/paging to minimize the amount of data being passed around. I don't

How to make a MVC 3 Webgrid with checkbox column?

最后都变了- 提交于 2019-12-29 04:44:05
问题 The code below will insert an actionlink into one of the web grids' columns. @{ View.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; var usersGrid = new WebGrid(source: Model, rowsPerPage: 40); } @usersGrid.GetHtml( tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt", columns: usersGrid.Columns( usersGrid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.Id})), usersGrid.Column("Surname") ) ) But if i exchange that line for this: usersGrid

Filter is getting lost in WebGrid + Paging + Sorting + Filtering in .NET 4.0

坚强是说给别人听的谎言 提交于 2019-12-28 06:20:08
问题 I've implemented a WebGrid. Sorting, paging and filtering do not work together. They work when you use them alone. When you combine the three, at the same time, filtering doesn't work. The symptom: Filter the resultset, then sort. or Filter the resultset, then go to next page. In both cases, the filter is lost. But it does page and sort. In the code behind: When the action method is called via a sort or pagination, nulls show for each of the filter parameters. When the action method is called

Filter is getting lost in WebGrid + Paging + Sorting + Filtering in .NET 4.0

喜你入骨 提交于 2019-12-28 06:20:01
问题 I've implemented a WebGrid. Sorting, paging and filtering do not work together. They work when you use them alone. When you combine the three, at the same time, filtering doesn't work. The symptom: Filter the resultset, then sort. or Filter the resultset, then go to next page. In both cases, the filter is lost. But it does page and sort. In the code behind: When the action method is called via a sort or pagination, nulls show for each of the filter parameters. When the action method is called

Ajax Result not Updating Web Grid Automatically MVC 4

匆匆过客 提交于 2019-12-25 05:36:17
问题 View Script function AddToBag() { var url = "/Home/Populate_Entitle/"; $.ajax({ url: url, data: { id: 1 }, cache: false, type: "POST", success: function (data) { alert("hi"); $("#gridContent").html(markup); }, error: function (reponse) { alert("error : " + reponse); } }); } Controller Functions public ActionResult Populate_Entitle(int id) { if (dtEntitle.Columns.Count == 0) { dtEntitle.Columns.Add("sno"); dtEntitle.Columns.Add("Sport"); dtEntitle.Columns.Add("Event"); dtEntitle.Columns.Add(

clickable rows in web grid, with razor/javascript

我怕爱的太早我们不能终老 提交于 2019-12-24 10:48:41
问题 Using the webgrid helper I've used some JavaScript to have the entire row clickable, and that works fine, however the href link in the JavaScript i need to incorporate razor. javascript code here: <script type="text/javascript"> $(function(){ $('tbody tr').live('hover', function(){ $(this).toggleClass('clickable'); }).live('click', function(){ location.href = '/Messages/Reply/' + $(this).find('td:first').text(); }); }); </script> But this code is taking the value in the first cell and using

ASP.NET MVC Webgrid Efficient Paging

随声附和 提交于 2019-12-24 10:47:31
问题 I have a ASP.NET MVC 4 project and a SQL View (vvItem). ItemController MVCAppEntities db = new MVCAppEntities(); public ActionResult Index() { var itemqry = db.vvItem.OrderBy(s => s.name); //var pageditems = itemqry.Skip(10).Take(20); // 25 seconds return View(itemqry.ToList()); // 88 seconds } Index.cshtml View @model IEnumerable<MVCApplication1.Models.vvItem> @{ var norows = 20; var grid = new WebGrid(Model, canPage: true, rowsPerPage: norows); grid.Pager(WebGridPagerModes.NextPrevious);

Show a tooltip with more info when mousover a MVC3 Razor WebGrid row

时光总嘲笑我的痴心妄想 提交于 2019-12-24 08:39:35
问题 I have a grid with a list of persons. On mouseover a certain persons row I would like to show additional info (photo, address etc) in a tooltip. All the needed data exist in the model, but I don't know how to add the tooltip functionality inside the grid. I also wonder if the jquery ui tooltip is a good choice for this? TIA :) 回答1: Here is the code sample to show tool-tip in asp.net mvc webgrid : grid.Column("LongTextColumn", "Column Header Here" , format: (item) => Html.Raw("<abbr style=

Conditionally display an image in webgrid

て烟熏妆下的殇ゞ 提交于 2019-12-24 08:18:48
问题 nemesv's code Conditionally display an image in webgrid - mvc 3 works great in MVC3. @grid.GetHtml( displayHeader: false, columns: grid.Columns( grid.Column(format: (item) => { if (item.IsMainPreview == true) { return Html.Raw(string.Format("<text><img src=\"{0}\" alt=\"Image\"/></text>", Url.Content("~/Content/images/preview-photo.gif"))); } In MVC4 you don't need Url.Content to use the "~". I haven't been succesful in getting the code to work without the Url.Content (it can't find the image