0
votes

I have a kendo ui function dropdownlist, and it will call at Grid column editor. My question, by default how to display "Yes" when Add New Record in edit function. Currently it display null when Add New Record.

Demo in Dojo

Here I provide a working demo. Thank You

1

1 Answers

2
votes

If I understand correctly you only have to add a default value to the Price in the Model?

"Price": {type: "string", defaultValue: "y" }, 

I include the whole function, just in case:

$(function() {
  $("#grid").kendoGrid({
    dataSource: {
      data: [
       { Name: "Young John", Price: "y" },
       { Name: "John Doe", Price: "n" },
       { Name: "Old John", Price: "y" }
      ],
      schema: {
        model: {
          id: "id",
          fields: {
            "id": { type: "number" }, 
            "Price": {type: "string", defaultValue: "y" }, 
          }
        }
      }
    },
    editable: "inline",
    toolbar: ["create"],
    columns: [{ field: "Name"}, 
              { field: "Price",
                        template: "#=(data.Price == 'y' ? 'Yes' : 'No')#",
                editor: radioPrice
              } ],
    edit: function(e) {     
       if (e.model.isNew()) {       
                        e.model.Price = 'y';
       }
    }
  });
});