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

[Solved] ClientTemplate for NumericTextBox

4 Answers 213 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bata
Top achievements
Rank 1
bata asked on 27 Feb 2011, 04:02 PM
I am using the Numeric Text Box inside the Grid cell. It works perfectly in Server mode:
columns.Template(oi =>
                                               {%>
                                                 <%=
                                                       Html.Telerik().NumericTextBox()
                                                                        .AssetKey("ReturnQuantity_" + oi.OrderItemId)
                                                                        .DecimalDigits(2)
                                                                        .EmptyMessage(Server.HtmlDecode(Html.T("QuantityToReturnValidationMsg")))
                                                                        .MinValue(0)
                                                                        .MaxValue(oi.QuantityAsDouble)
                                                                        .IncrementStep(oi.QuantityIncrementalStep)
                                                                        .Value(oi.QuantityAsDouble)
                                                                        .Name("QuantityToReturn_" + oi.OrderItemId)
                                                                        .InputHtmlAttributes(new { style = "width:60px" })
                                                                        .ToHtmlString()
                                                 %>                                                                                                                    
                                             <%
})
                              .Title(Server.HtmlDecode(Html.T("QuantityEdit"))).Width(25).HtmlAttributes(
                                  new { style = "text-align:center" })

However, as I am using also Ajax grid binding with paging, sorting, etc... I need the same thing but in ClientTemplate mode.
I tried a lot of combination, but simple I can't force NumbericTextBox to work in that mode. The main problem is that I can't use Double as data type but its necessary for MinValue and MaxValue as well as for Value.
Any suggestion?

4 Answers, 1 is accepted

Sort by
0
bata
Top achievements
Rank 1
answered on 05 Mar 2011, 10:27 AM
Anyone?
0
Ferry
Top achievements
Rank 1
answered on 08 Mar 2011, 09:04 AM
Same problem here, any solution?

columns.Bound(o => o.RTPercen).ClientTemplate(Html.Telerik().NumericTextBox().Name("<#= Id #>").Value(Convert.ToDouble("<#= RTPercen #>")).ToHtmlString()).Width(100);

RTPercen data type is double.
 
Thanks
0
Atanas Korchev
Telerik team
answered on 08 Mar 2011, 09:10 AM
Hello,

This  is not currently supported. You cannot pass JavaScript argument to the server-side Value method. You can try using the OnRowDataBound client-side event to set the numeric value.

Regards,
Atanas Korchev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Ferry
Top achievements
Rank 1
answered on 08 Mar 2011, 12:34 PM
Thanks Atanas, Great Solution !!

.Columns(columns =>
    {
        columns.Bound(o => o.RTPercen).ClientTemplate(Html.Telerik().NumericTextBox().Name("RTPercen" + "<#= Id #>").Value(0).ToHtmlString()).Width(100);
    })
    .ClientEvents(events => events.OnRowDataBound("onRowDataBound"))

And for client-side onRowDataBound :

function onRowDataBound(e) {
        var dataItem = e.dataItem;
        var $numtxt = $(e.row).find("#RTPercen" + dataItem.Id);
        $numtxt.data("tTextBox").value(dataItem.RTPercen);
    }

Tags
NumericTextBox
Asked by
bata
Top achievements
Rank 1
Answers by
bata
Top achievements
Rank 1
Ferry
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or