This is a migrated thread and some comments may be shown as answers.

Conditionally visible custom command?

5 Answers 939 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 19 Apr 2012, 01:26 PM
Is it possible to have custom commands that are only rendered if some property in the data row is set?

I thought of data looking something like this:
[
{name:"Olivia", email:"olivia@olivia.com", showContactInfo: 1 },
{name:"Michael", email:"michael@yahoo.com",showContactInfo: 0},
{name:"Peterl", email:"pe@ter.com",showContactInfo: 0}
]

The idea is that you could:
if (showContactInfo) // make the custom command visible for this row

Another way to go could be a detail template, which was only accessible for some rows depending on the condition?

/Thomas

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 19 Apr 2012, 01:37 PM
Hi Thomas,

You can use a row template with expressions (IF statements) inside.

All the best,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Thomas
Top achievements
Rank 1
answered on 20 Apr 2012, 10:08 AM
Hi
I have tried this, but I get an "unterminated string literal error"

My columns definition looks like this:
columns: [
{ field:"name", title: "name" },
{ field:"drugId", title: "drugId" },
{ field:"form", title: "form" },
{field:"strength", title:"strength"},
{ field: "dspNumber",
title:"DSP",
template: "#if (dspNumber) # <button>do stuff</button> "  }
 ]

Have I missed something in my template condition?

/Thomas
0
Dimo
Telerik team
answered on 23 Apr 2012, 12:49 PM
Hi Thomas,

Please compare the following example with your implementation.

http://jsfiddle.net/dimodi/LhmDD/

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Thomas
Top achievements
Rank 1
answered on 23 Apr 2012, 01:39 PM
Thanks.
I solved it by using a template in a script tag instead of inlining it in the columns array.
I still get the "unterminated string literal" error, if I use your jsfiddle example - but the very same code in a script tag works.

Best,
Thomas
0
Joshua
Top achievements
Rank 1
answered on 26 Apr 2012, 03:47 PM
I am trying to create custom commands that will put rows into inline edit mode. Just like when a row goes into edit by default, I want to change the function of my custom edit button to a custom save button. the problem that I am having is that the "editor" property is ignored if there is nothing in the "field" property.

Also when i put a row into edit mode and then come out of edit it does not retain the click binding.

example:

http://jsfiddle.net/LhmDD/3/ 

Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Thomas
Top achievements
Rank 1
Joshua
Top achievements
Rank 1
Share this question
or