Hide column in view, render as checkbox

QuestionsHide column in view, render as checkbox
Kelys asked 6 years ago

Hello.

How can I hide a column in grid view but show it when inserting/editing a record (it's a password column)?
Also, I need to render a boolean (TINYINT 0: false, -1:true) field as a checkbox. This works fine in editing mode but not in view mode.

Thank you.

3 Answers
Abu Ghufran answered 6 years ago

To hide column in list, show otherwise, you can set

$col["hidden"] = true;
$col["editrules"] = array("edithidden"=>true);

To display column as checkbox, use
$col["formatter"] = "checkbox";

Kelys answered 6 years ago

Thank you, the password setting works great. However, in display mode, the checkbox stays in unchecked state even though the column's value is -1 (true). Is there something like

$col["editoptions"] = array("value"=>"-1:0");

for display mode?
Thanks

Abu Ghufran answered 6 years ago

Yes, it works for display mode too.
I verified these settings with tinyint and -1:0.

$col = array();
$col["title"] = "Closed";
$col["name"] = "closed";
$col["width"] = "50";
$col["editable"] = true;
$col["edittype"] = "checkbox"; // render as checkbox
$col["editoptions"] = array("value"=>"-1:0"); // with these values "checked_value:unchecked_value"
$col["formatter"] = "checkbox";
$cols[] = $col;

Your Answer

13 + 7 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!