开发者

How To: Custom Edit Column name and Value in a Telerik Grid

I am kind of a newbie to MVC and Telerik and working on a project that involves both of them, the problem am facing currently is: Am using teleirk Grids extension with Grid Method (DataTable) bound to a DataTable:

<% var table = ViewData["NewDesigns"] as DataTable;

Html.Telerik() .Grid(table) .Name("oi") .P开发者_运维技巧ageable(pager => pager.PageSize(100)) .Groupable() .Sortable() .Columns(columns => { columns.Bound(r => r.category).Title("Category"); }) .Render(); %>

The grid is being displayed fine but there are two things that I want to do:

  1. Change the column name to my custom heading/title
  2. Eid Datatable content before printing it in a grid: For e.g.: if id column has a value ‘21’, I want to print it in as hyper-link 21

I've spent time in telerik help files and learned a lot but not able to find answer of these, ld appericiate if someone here could help me out.

DataTable Object:

    ordr    {myprod.Models.Orders}  myprod.Models.Orders addrss null    string cntact   null    string custmrNam    null    string dlivrdn  null    string dsignr   null    string dsignId  null    string mail null    string id   null    string rdrCd null   string rdrdn    null    string quantity null    string siz  null    string status   null    string ttalPric null    string twn  null    string usrId    null    string'


The following example with custom titles and custom templates might help:

Html.Telerik()
    .Grid(table)
    .Name("ordersInum")
    .Columns(columns =>
    {
        columns.Bound(typeof(Int32), "ID").Title("Row ID").Template(Html.ActionLink(item.ID, "Detail", new { r.ID }));
        columns.Bound(typeof(string), "Name").Title("Product").Template(@<text>
                <img src="images/product.png" />
                @item.Name
            </text>);
        columns.Bound(typeof(Double), "Price").Title("Price in $");
        columns.Bound(typeof(DateTime?), "OrderDate").Format("{0:MM/dd/yyyy}").Width(80);
    })
    .Pageable(pager => pager.PageSize(100))
    .Groupable()
    .Sortable()
    .Render();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜