javascript - Conditionally expand row in kendo grid -
in kendo grid, trying check if 1 of column fields true or false. if true, row should expanded, if false, row should stay collapsed. code definition column is:
{ field: "comment", title: txt.txt_comment, template: '<input type="checkbox" #= comment ? "checked" : "" # disabled="false" ></input>', }, my code condition in databound checking if there data:
databound: function (e) { var data = this.dataitem; if (data.comment == 1) { this.expandrow(this.tbody.find("tr.k-master-row")); } f_ondatabound(e); } thanks help!
you on right direction using databound event. need after is, iterating through rows , check specific model property , expand, or not, specific row.
var grid = $("#grid").data("kendogrid"); var data = grid.datasource.data(); var len = data.length; for(var = 0; < len; i++) { var row = data[i]; if(row.comment == '1') { // checks value of comment property grid.expandrow("tr[data-uid='" + row.uid + "']"); // expands row specific uid } } i tested , works perfectly. can't know what's on comment propery though, that's control , adapt javascript function if needed.
edit
i have created a fiddle demonstrates above strategy. in example databound function looks property "name" , expands row if "sally"
Comments
Post a Comment