webgrid

javascript not working in MVC webgrid after sorting or paging

荒凉一梦 提交于 2019-12-11 10:29:17
问题 I am newbie in MVC and trying to polish concepts on webgrid . I have the following code in view @model IEnumerable<MVCMovies.Models.Movie> @{ ViewBag.Title = "Index"; } <script type="text/javascript"> $(function() { $('tbody tr').on('hover', (function () { $(this).toggleClass('clickable'); })); $('tbody tr').on('click', (function () { alert('rajeev'); })); }); </script> <style type="text/css"> .table { margin: 4px; width: 100%; background-color: #FCFCFC; } .head { background-color: #11E8CD;

ASP.NET MVC 3.0 WebGrid - Ajax Enabled

心不动则不痛 提交于 2019-12-11 09:26:47
问题 I'm encountering the following problem: "A JQuery script reference is required in order to enable Ajax support in the "WebGrid" helper" I want to make my WebGrid AJAX enabled. I got this code for the Partial View @ModelType WebGrid @Model.GetHtml(tableStyle:="webgrid", headerStyle:="webgrid-header", footerStyle:="webgrid-footer", alternatingRowStyle:="webgrid-alternating-row", selectedRowStyle:="webgrid-selected-row", rowStyle:="webgrid-row-style", columns:=Model.Columns(Model.Column(

MVC3 WebGrid header alignment

孤街浪徒 提交于 2019-12-11 08:53:06
问题 WebGrid (Razor) How can the headers alignment be set? I need to be able to change the alignment for each column (could be different) It seems to be a all or nothing deal nor does it seem to take the alignment of the child TD. 回答1: There currently is not a way to set a different style for each column header using the WebGrid in MVC 3. You can however use the tableStyle property to set the style for all column headers. .header { text-align: left; } @var grid = new WebGrid(Model); @grid.GetHtml

ASPX View MVC3 WebGrid format column

試著忘記壹切 提交于 2019-12-11 07:41:45
问题 <%{ WebGrid studentGrid = new WebGrid(rowsPerPage: StudentController.PageSize); studentGrid.Bind(Model.Students, autoSortAndPage: false, rowCount: Model.RowCount); studentGrid.PageIndex = Model.CurrentPage; }%> <%=studentGrid.GetHtml(columns: new WebGridColumn[]{ studentGrid.Column("StudentId", "Id"), studentGrid.Column("Name", "Name"), })%> Unfortunatly i am forced to use aspx view in my MVC3 project. I want to have a column that shows a text "select" or "remove" based on some condition of

Delete row in webgrid with checkboxes in MVC3 using Visual Studio 2012

孤街醉人 提交于 2019-12-11 02:41:10
问题 I am new to MVC3. I have coded an application in which I display data into a webgrid with checkboxes. I am trying to find out how to send a particular row id the controller action method when I click on a checkbox. Any help appreciated. 回答1: This all depends on what you are trying to do. Typically, in the view, I will add a data attribute like data-rowid="###" and then use jQuery to capture the .click event. Then in the .click event, retrieve the clicked elements value for data-rowid and call

How to write IF condition in column of Web grid

谁都会走 提交于 2019-12-11 02:37:42
问题 i have get error the create the if condition in to column of WEB GRID so...please help to improve my code and solved to my prob.... grid.Column("Status", format: item => @<text> @if (item.Is_active = true) { @<a href="Url.Action("UserStatus", "Admin")"><img src="../../images/Active.png"/></a> } else { @<a href="Url.Action("UserStatus", "Admin")"><img src="../../images/Deactive.png"/></a> } </text>), 回答1: The following should work: grid.Column( "Status", format: @<a href="@Url.Action(

Webgrid not refreshing after delete MVC

試著忘記壹切 提交于 2019-12-11 02:32:24
问题 I am deleting a row in my webgrid , and redirecting to my GET index as normal after delete. However as expected my view is showing the old deleted row still in the grid. I know this is by design and i should be able to set the Modelstate to clear , or remove the item individually to achieve this : ModelState.Remove("id"); Or foreach (var key in ModelState.Keys.Where(m => m.StartsWith("id")).ToList()) ModelState.Remove(key); Or ModelState.Remove("Applicant.ApplicantId"); Or even : ModelState

web grid sorting not working mvc 3 razor

ε祈祈猫儿з 提交于 2019-12-11 01:36:33
问题 I am using MVC 3 with Razor and I am using the below web grid to show some data, What I need sorting on my first column. I have used similar code on other pages too for my sorting and it works fine, but here it doesnt seem to work. However if I go to the next page say page 2 and now I click sort, it is sorted ascending and then again same problem. <div id="grid"> @{ // added ajaxContainerId var listgrid = new WebGrid(source: Model.ABC, rowsPerPage: 2, ajaxUpdateContainerId: "grid"); @listgrid

How to hide header on MVC3 WebGrid

浪尽此生 提交于 2019-12-10 19:12:58
问题 Is there some easy way to hide header for MVC3 WebGrid extension? Something like var grid = new WebGrid(Model, canSort:false, canPage:false, showHeader:false); I can probably set css style for header that will cause header not showing, though I'd rather have this done via code. Thanks, Antonin 回答1: You could pass it to the GetHtml method: @grid.GetHtml(displayHeader: false) For additional options you may take a look at the following blog post. 回答2: write down column index in eq() and it will

Header Format for WebGrid

泪湿孤枕 提交于 2019-12-10 18:20:08
问题 I just read: http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid and see a reference to [Optional, Default Value(null)] string header Header text if you don't want database field names But I'm not sure how to format cell values. For example, if I have a WebGrid that looks like this: Column Name Column Name Column Name Column Name Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell