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

[Solved] Setting value of fields on check box change

1 Answer 10 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jijesh
Top achievements
Rank 1
Jijesh asked on 20 Nov 2012, 07:32 PM
hello,

Referring to the demo http://demos.telerik.com/aspnet-mvc/grid/editingajax , Is it possible to set values on other fields when the check box value changes.. ie, if we check the check box then the value in Product Name should display as "abc" by default.

Thanks for the help:)
J


1 Answer, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 07 Dec 2012, 05:29 PM
Hi JiJesh,

You may have to convert the fields into ClientTemplates to retrieve their values using jQuery.

function Grid_onRowDataBound(e) {
    //the DOM element (<tr>) representing the row which is being databound
    var row = e.row;
    //the data item - JavaScript object.
    var dataItem = e.dataItem;
    var grid = $("#GirdViewName").data("tGrid");
     
    // find the checkbox defined in the template column
    // and subscribe to its change event
    $(row).find("input:checkbox")
        .change(function () {
            // input elements in the row
            if ($(this).is(":checked")) {
                // get the values of client templates
                //alert("Checkbox checked");
                var textbox1 = $(row).find("#NameOfInput1").val();
                var textbox2 = $(row).find("#NameOfInput2").val();
                // do something with the values...
            }
            else {
                // additionally assign values
                $(row).find("#NameOfInput1").val() = 'abc';
                }
        });
 
}

Hope this helps.
Jason
Tags
General Discussions
Asked by
Jijesh
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Share this question
or