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

Make column in Grid non-editable after value is set from another column in Grid

0 Answers 185 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
K asked on 11 Oct 2012, 10:45 PM
Hello!  I am working with a kendo grid control and it is pulling data from a remote source.  The grid has a drop-down for one column, which when selected, will populate another field.  All that is working fine.  The issue I have is that, the field that is being populated by the drop down should be non-editable in the grid. 

Ok, so I thought to just update the data source > model > field > editable: property for the field I want.  This does make the column non-editable, but when I select the drop-down on column 1, the non-editable field never gets updated based on the drop-down field.  I was debugging and saw that when the editable property is set to false, the field will never get set.

However, let's say that I already had a form saved to the db.  When I open this form and it pulls the data from the db, the grid will display the correct value for the drop-down column 1, and correct value for the column 2 which is based on column 1.  So I am thinking that it is a timing thing, where if the form is pulling from the db, the value is set on cols 1 and 2 before the code hits and reads the editable property for col 2?

Is there a way to make a column in a grid non-editable after it has been rendered?  Or is there a way to default the column to non-editable, but ensure the change event on the drop-down is able to populate the other column?

The save fn() of the grid is below.  It sets the SerialNo field just fine if the column is editable, but if not, it will never set it.  I wonder if there is a reference, say to e.model.field.editable?

save: function (e) {
  if (e.values["FA_No_"]) { 
    //Select below loops thru all values in ddl and if it = FANo,
    //then set the other fields based off the FA.
    //If we set the FANo field somewhere above, it does NOT trigger the
    // or .change(), so we create inline select() below to
    //set the fields we need.
    //NOTE: 'e.model' refers to datasource model fields and the
    //faddl.dataItem refers to the ddl datasource fields.
    var currFA = e.values["FA_No_"];
    var faddl = $("#ddFA").data("kendoDropDownList"); (dataItem) {                                   
      if (dataItem.Code == currFA) {
        //First reset all values based on FANo.
        e.model.set("Description", "");
        e.model.set("Serial_No_", "");
        //Next, update all values based on newly selected FANo.
        if (dataItem.SerialNo)
          e.model.set("Serial_No_", dataItem.SerialNo);
        return dataItem.text === currFA;

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question