How Add fake row in Grid helper Telerik to ASP.NET MVC - asp.net-mvc

I need to add a line in the thead of table that going contenter inputs and selects that are used as parameters for filtering.
It is more or less how I wanted to stay:
<table>
<thead>
<tr>
<th> Name </ th> ...
<th> Type </ th>
</tr>
<tr> <!-- this is the 'tr fake' in thead -->
<th> <input type="text"/> </ th>
<th> <select name="nb"> ...</ select> </ th>
<tr>
</thead>
<tbody> .....
</table>
How do I add the this tr in table using the helper telerik grid for ASP.NET MVC?

Telerik ASP.NET MVC 2010 Q3 Beta has Custom Toolbar template functionality implemented. An example can be seen in demo which actually does implement pretty much what you want.

Related

MVC Turn model text into clickable link

I have an MVC Razor view that pulls change log information from a database (a table which only I have access to, limiting security concerns).
<table class="table">
<tr>
<th>
#Html.DisplayNameFor(model => model.Description)
</th>
</tr>
#foreach (var item in Model) {
<tr>
<td>
#Html.DisplayFor(modelItem => item.Description)
</td>
</tr>
}
</table>
The description will contain values like New page available: http://localhost:0000/app/NewItem. What I'm trying to figure out is how to make that web address active.
I.e., turn New page available: http://localhost:0000/app/NewItem
into: New page available: http://localhost:0000/app/NewItem
and have the link properly rendered on the page. Is there a simple way to accomplish this, short of using regular expressions in the controller to pull that link out?

Paging in MVC 5

In MVC 5, how to create paging for table? The following is a table structure.
<table class="table">
<tr>
<th>
Item ID
</th>
<th>
Item Name
</th>
<th>
Rate
</th>
<th>
Stock
</th>
</tr>
#foreach (var item in Model) {
<tr>
<td>
#Html.DisplayFor(modelItem => item.ItemID)
</td>
<td>
#Html.DisplayFor(modelItem => item.ItemName)
</td>
<td>
#Html.DisplayFor(modelItem => item.Rate)
</td>
<td>
#Html.DisplayFor(modelItem => item.Stock)
</td>
</tr>
}
</table>
I recommend the PagedList package which is available on nuget
https://www.nuget.org/packages/PagedList
Here is the full documentation
https://github.com/TroyGoode/PagedList
This tutorial has a good explanation of paging and how to install and use the packages:
http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application
I have found the solution. Using webgrid, we can achieve the paging
#model IEnumerable<ItemMaster>
#{
ViewBag.Title = "Item Details";
WebGrid grid = new WebGrid(Model,rowsPerPage:5);
}
<h2>Item Details</h2>
#grid.GetHtml()
Grid.MVC is an open source and working Grid with sorting and paging
(and unlike telerik you do not need to change anything on controller side just add reference in your view and use.)
To install nugget package (Install)
PM> Install-Package Grid.Mvc -Version 3.0.0
In your view you can auto-create columns as below (or customize see User Guide)
#using GridMvc.Html
#Html.Grid(Model).AutoGenerateColumns()
See Online Demo
you can look for DataTables jquery plugin here. It is a very powerful and light weight plugin that supports sorting and searching inside the table.

How do I write VB Inline html templates in Razor?

I am struggling with writing in-line templates in razor vb.
Here is a sample forms c# version. Can someone translate to RAZOR vb?
<%Html.GridView<Employee>(
this.ViewData.Model,
data => { %>
<table class="grid" cellpadding="0" cellspacing="0">
<tr>
<th> </th>
<th> </td>
<th> </td>
<th>Name</th>
<th>E-mail</th>
</tr>
<% },
It does not appear, even in the latest Visual Studio, that this was supported, which is very unfortunate. It does seem templates are supported to some degree (as taken from this), but not for complex control setups like you have above. Bummer.

Is it possible to modify ASP.NET MVC WebGrid so that it doesn't look like a regular grid table?

I need to render a table that doesn't look like a regular grid table, where for one entry, which would be a row in a typical table, columns 1 and 2 values can be put in row 1, columns 3, 4 and 5 values will be in row 2, and so on like so:
<table id="display_searchresults_student">
<tr>
<th rowspan="4"><img src="../../Images/picture_temp.jpg" id="display_searchresults_studentpicture"/></th>
<td id="display_searchresults_studentname">**Name Column**
<img src="../../Images/picture_temp.jpg" height="25px" width="25px"/>
</td>
<td align="right" width="100px">Rating Column</td>
</tr>
<tr>
<td id="display_searchresults_studentlocation">City Column, State Column | University Column</td>
<td></td>
</tr>
<tr>
<td id="display_searchresults_studentinfo">Department Column | School Standing Column Graduation Date Column | GPA Column</td>
<td></td>
</tr>
<tr>
<td id="display_searchresults_studentdesc" colspan="2">Comments Column...</td>
</tr>
</table>
This table will have multiple entries. The reason why I thought of using a WebGrid is because I need the sorting, filtering and paging capability. I now that Telerik allows constructing tables like that. However, I'm not seeing how to do it through the WebGrid. Is there a way to change the Webgrid's HTML prior to it being rendered without breaking the sorting, filtering and paging capabilities? Does jqGrid or other open-source grids allow to do something like that?
Thanks a lot in advance.
It's hard to tell what you are talking about without an example, but what about Masonry?

Does HTML5 ban th cells from tbody?

I have the following markup as a part of a Razor view:
<table>
<caption>Presidents</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Born</th>
<th scope="col">Died</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Washington</th>
<td>1732</td>
<td>1799</td>
</tr>
<!-- etc -->
</tbody>
</table>
With the "target schema for validation" set to HTML5, Visual Studio complains thusly:
Warning 1 Validation (HTML5): Element 'th' must not be nested within element 'tbody tfoot'.
Is this really true? If so, could someone link to the spec?
My understanding was that using <th> for row headers was not just legal but encouraged. It certainly seems fairly common, I could link dozens of tutorials explaining (seemingly sensibly) that it helps with accessibility.
Is this a VS bug? A real change coming with HTML5 (a good one? a bad one?)? What's the story?
My understanding was that using <th> for row headers was not just legal but encouraged
As far as I know, this was always legal in HTML 4 (and possibly its predecessors), and hasn't changed in HTML5.
W3C's HTML5 validator, while still experimental, reports no warnings or errors. Then again, I'm sure the HTML5 validation Visual Studio is using is experimental as well since HTML5 itself hasn't yet been finalized.
The HTML5 spec on marking up tabular data, specifically section 4.9.13, shows the use of <th> within <tbody> and <tfoot> to scope row data:
<table>
<thead>
<tr>
<th>
<th>2008
<th>2007
<th>2006
<tbody>
<tr>
<th>Net sales
<td>$ 32,479
<td>$ 24,006
<td>$ 19,315
<tr>
<th>Cost of sales
<td> 21,334
<td> 15,852
<td> 13,717
<tbody>
<tr>
<th>Gross margin
<td>$ 11,145
<td>$ 8,154
<td>$ 5,598
<tfoot>
<tr>
<th>Gross margin percentage
<td>34.3%
<td>34.0%
<td>29.0%
</table>
So it's perfectly legitimate to have <th> elements inside <tr> elements inside either a <tbody> or <tfoot>. As it should be anyway, since table headings aren't just found on table headers.
The HTML5 spec only requires that it be inside a tr, and the spec actually includes an example with a th nested inside a tbody.
Generally a TH in a THEAD will have a scope value of "col" while a TH in a TBODY will have a scope value of "row".

Resources