Kendo Grid: how to get the selected item from a Combobox cell template when using with Angular

前端 未结 2 426
感情败类
感情败类 2021-01-24 13:11

I have a Kendo grid which I am using within Angular, and have a field with a combo box, that has the editor set to the following function...

 function comboCellT         


        
2条回答
  •  梦毁少年i
    2021-01-24 13:45

    Ok, I think I have got to the bottom of this (after lots of diving through the doco)

    I could get everything to work after I discovered that you can give a column a "magical" compare function.

    So using this, my field can go back to binding to the whole json object .. and add the sortable as follows...

    {
      field: "Category",
      title: "Category",
      editor: comboCellTemplate,
      template: "#=Category.description#",
      sortable:{
            compare: function (a, b){
              return a.Category.description.localeCompare(b.Category.description);
            }
    

    },

    Now everything works exactly as I expect, and I don't need to do anything extra in the combobox. I hope this ("simple when you know how") tip can save someone else all the time it took me to find it.

提交回复
热议问题