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

[Solved] Unable to update input fields in Grid Inline Edit Mode through jQuery

2 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.
veerendra potru
Top achievements
Rank 1
veerendra potru asked on 20 Feb 2012, 08:41 AM

 

I have a MVC Grid which is bound to Employee collection. There are two calculated fields(Calc1,Calc2) that need to be calculated based on the input of the age.
 
@(Html.Telerik().Grid(Model.Employee)
.Name("Grid")
.DataKeys(keys => keys.Add(p => p.EmployeeID).RouteKey("EmployeeID"))
.Columns(columns =>
{
columns.Bound(x => x.FirstName).Width(120).ReadOnly();
columns.Bound(x => x.LastName).Width(120).ReadOnly();
columns.Bound(x => x.Age);
columns.Bound(x => x.Calc1).ReadOnly();
columns.Bound(x => x.Calc2);
}
)
.Localizable("fr-FR")
.ClientEvents(events => events.OnEdit("onRowEdit").OnRowDataBound("OnRowDataBound"))
)
 
 function onRowEdit(e) {
$("#Age").bind('blur', function () {
      $("#Grid .t-grid-edit-row")[0].cells[3].innerHTML = "some value";  //Working file
      $("#Calc2").get(0).value = "some value";// Working fine if UIHint attribute is not specified on the Calc2 field
 });
}
 
 
 
Because, Calc2 cell is input type during editing type, I could update the textbox with the following syntax.
$("#Calc2").get(0).value = some value;// Working file
 
But the input type textbox not updating(value not reflecting) if I set [UIHint("Number")] attribute on Calc2 field.
[UIHint("Number")]
public decimal Calc2 {get; set;}
 
public class Employee
{
    public string FirstName{get;set;}
    public string LastName{get;set;}
    public string Age{get;set;}
    [UIHint("Number")]
    public decimal Calc1{get;set;}
    [UIHint("Number")]
    public decimal Calc2{get;set;}
}
Please suggest me how to achieve this with UIHint attribute.

2 Answers, 1 is accepted

Sort by
0
gkennedy
Top achievements
Rank 1
answered on 25 Mar 2012, 10:49 PM
Is there nobody at Telerik that knows the answer to this? I've been searching for a while for a clue on why this happens and I keep finding unanswered questions in this forum.
0
Dadv
Top achievements
Rank 1
answered on 26 Mar 2012, 09:40 AM
Hi,

i'm not really sure of what you want, but if i'm not false you want to update automatically a field when an other is modify (on the fly in client side).

Your problem is that if you use [UIHint("Number")] you can't do it as normally because the edit template (i assume it is telerik numeric textbox) use an other way for the update functionality.

here the documentation :

function setValue() {
   var numberTextBox = $("#Calc2").data("tTextBox");
   var newValue = 12.10
   numberTextBox.value(newValue);
}

function getValue() {
   var numericTextBox = $("#Calc2").data("tTextBox");
   var value = numericTextBox.value();
}

Note that the value is a number not a string....

Tags
Grid
Asked by
veerendra potru
Top achievements
Rank 1
Answers by
gkennedy
Top achievements
Rank 1
Dadv
Top achievements
Rank 1
Share this question
or