This is a migrated thread and some comments may be shown as answers.

[Solved] Display value inside button

6 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sam
Top achievements
Rank 1
Sam asked on 05 Apr 2012, 04:34 PM
Hi,

How can I display the order id in the button?  Thanks!

      @(Html.Telerik().Grid<MvcTestTelerik.OrderListModel>()
            .Name("Grid")
            .Resizable(resizing => resizing.Columns(true))
            .Columns(columns =>
                {
                    columns.Bound(o => o.OrderId).Title("Order Number")
                        .Width(40);

                    columns.Command(cmd => cmd
                        .Custom("Go")
                         .DataRouteValues(route =>
                            {
                                route.Add(o => o.OrderId).RouteKey("orderId");
                            })
                        .Ajax(true)
                        .Action("ActionResult", "Home"))
                        .Width(40)
                        .Title("Order Number");
                       
                  
                    columns.Bound(o => o.ord_status).Format("{0:MM/dd/yyyy hh:mm tt}").Title("Order Status").Width(40);
                    columns.Bound(o => o.PONumber).Title("PO Number").Width(40);
                    columns.Bound(o => o.username).Title("User Name").Width(40);
                    columns.Bound(o => o.ReceivedDate).Title("Order Date").Width(40);

                })
                        .ClientEvents(clientEvents => clientEvents.OnDataBinding("dataBinding").OnRowSelect("onRowSelected"))
                .DataBinding(db => db.Ajax().Select("OrderList", "Home"))
                .Pageable(paging => paging.PageSize(20)
                    .Style(GridPagerStyles.NextPreviousAndNumeric)
                    .Position(GridPagerPosition.Bottom))
                .Scrollable()
                .Sortable()
                .Selectable()
            )

6 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 06 Apr 2012, 11:09 AM
Look at the OnRowDatabound event, use the 'row' property, find the command link ('a .t-grid-edit'), change it 'val()' by e.dataItem.OrderId


Edit : correct the OrderId property
0
Liem
Top achievements
Rank 1
answered on 06 Apr 2012, 03:51 PM
Hi Dadv,

This is what I have:

 function onRowDataBound(e) {
        $(e.row).find('a .t-grid-edit').val(e.dataItem["OrderId"]);
    }

It still does not work.  Maybe I did not do correctly.  See attached.  Thanks.
0
Dadv
Top achievements
Rank 1
answered on 06 Apr 2012, 04:04 PM
e.dataItem["OrderId"] => e.dataItem.OrderId
0
Liem
Top achievements
Rank 1
answered on 06 Apr 2012, 05:02 PM
I'm sorry I don't understand what you are saying.  I'm very new at this.  Thanks.
0
Dadv
Top achievements
Rank 1
answered on 06 Apr 2012, 05:12 PM
replace 
function onRowDataBound(e) {
        $(e.row).find('a .t-grid-edit').val(e.dataItem["OrderId"]);
    } 

by 

function onRowDataBound(e) {
        $(e.row).find('a .t-grid-edit').val(e.dataItem.OrderId);
    } 
0
Liem
Top achievements
Rank 1
answered on 06 Apr 2012, 05:16 PM
Thanks.  but it did not work.  It is the same before. :-(
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Liem
Top achievements
Rank 1
Share this question
or