1
votes

I have a boolean isActive that returns TRUE or FALSE

           {
                field: "isActive",
                title: "Status",
                width: 90

            }

I've managed to make this work and in the grid it will show 'true' or 'false'. However I want to make it if its true, change field to A and if false change title to B. How can I do this?

EDIT: This is how they are written usually (field,title, width, template etc). IsActive is a boolean, and I want it to perform a check (if isActive = true, return A. Not sure how to explain it. Currently it its displaying the boolean value (true/false) and I want it to display Active/Inactive in the grid. Sorry for the confusion, the title will remained unchanged

3
What is field? What is A? Which title? When do you want to check? On change? Periodically? Be more specific + provide more code.m02ph3u5
Try to edit your question rather than adding this as a comment to improve the quality of your question. You can delete the comment afterwards (even with low rep I guess)m02ph3u5
okay thanks! hopefully someone understands what I'm trying to achieveBuda Cristian
I think you can get that done with a hash template. Try something like field: "#= isActive == 'true' ? 'Active' : 'Inactive' #" Otherwise you might be able to just use a javascript function. You may need to debug to see what isActive is stored as. docs.telerik.com/kendo-ui/framework/templates/overviewSteve Greene

3 Answers

2
votes

You can use a column template function (http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.template):

{ field: "isActive",
  template: function(dataItem){
      return dataItem.isActive ? "Active" : "Inactive";
  }
}

DEMO

1
votes

I think that better solution could be:

{
    field: "isActive",
    title: "Status"
    values: [{ text: 'Yes', value: true }, { text: 'No', value: false }]
}

it also enables combo box in filters

0
votes

use template

 { field: "isActive", title: "isActive", template: "#= isActive ? 'Yes' : 'No' #", width: "100px" }