$col['edittype'] = "button"

Questions$col['edittype'] = "button"
Craig Nicholls asked 10 years ago

Can you please explain how this works? It always seems to render as a null column, no matter what the value of $col["editoptions"].

The documentation seems somewhat silent on the matter.

5 Answers
Abu Ghufran answered 10 years ago

Hi,

Only certain edittypes are allowed.
However you can use $col["default"] to specify any html you want in cell, so you can put

$col["default"] = "<button> …. ";

For reference, please check demo > appearence > custom-buttons.php

Craig Nicholls answered 10 years ago

OK. However, the documentation here (http://www.phpgrid.org/docs/) says…

Render as button
$col["edittype"] = "button";
$col["editoptions"] = array("value"=>'Click Me');

…is the doc incorrect or just incomplete?

Abu Ghufran answered 10 years ago

I think there is some confusion.

The edittype > button, will show button when the record is in edit mode, and it work with this code, and not in display mode.

$col = array();
$col["title"] = "Button"; // caption of column
$col["name"] = "button";
$col["width"] = "50";
$col["editable"] = true;
$col["edittype"] = "button";
$col["editoptions"] = array("value"=>'Click Me');
$cols[] = $col;

If you wish to display button in display mode (non-edit), you have to use this property.

$col["default"] = "<button> …. ";

For $col["default"], you can refer the demo of custom-button.php

Frederik answered 8 years ago

(Licensed Version)
Hello, and what if i want that the

$col["default"] = 'my html code'

shows only when the user doubleclick the field to edit it?

Abu Ghufran answered 8 years ago

You can set:

$col["editoptions"]["dataInit"] = "function(o){edit_custom(o);}";
$cols[] = $col;

… and in html section, we can define custom edit-type display

<script>
function edit_custom(o)
{
setTimeout(function(){
jQuery(o).replaceWith('my html code');
},100);
}
</script>

Refer docs: Render Radio buttons as edittype

Your Answer

0 + 8 =

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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?