Nixoderm
Nixoderm

Reputation: 355

Kendo UI Dropdownlist checked

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

Upvotes: 0

Views: 153

Answers (1)

Jörgen Moen
Jörgen Moen

Reputation: 343

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';
       }
    }
  });
});

Upvotes: 2

Related Questions