col values in custom event

Questionscol values in custom event
Ananda Theerthan asked 6 years ago

Hi,
I have 3 cols in my grid.
col1 and col2 visible and not editable.
col3 is editable.
When data is saved, i want to validate whether col3 value greater than col2 and col1.
there is no value returned in variable r.
can you please help.

5 Answers
Abu Ghufran answered 6 years ago

Hello,

1,2) For multi-inline edit, you can have grid like http://www.phpgrid.org/updates/open-grid-in-edit-mode-by-default/
3) This is doable via server side validation. For e.g.

$e["on_update"] = array("edit_client", null, false);
$grid->set_events($e);
function edit_client($data)
{
if ($data["params"]["col3"] + $data["params"]["col4"] > $data["params"]["col5"])
phpgrid_error("Invalid entry, My custom error message");
}

Refer demos/editing/server-validation.php for code example.

Abu Ghufran answered 6 years ago

In addition to above, To make column available on server side callback, it must be editable.

if you want few columns to be non-editable, you can have actual columns are editable – hidden, and 2 virtual columns that are non-editable & visible.

$col = array();
$col["title"] = "Col2";
$col["name"] = "col2";
$col["width"] = "200";
$col["editable"] = true;
$col["hidden"] = true;
$cols[] = $col;

// virtual column
$col = array();
$col["title"] = "Col2";
$col["name"] = "col2-virtual";
$col["width"] = "200";
$col["editable"] = false;
$col["hidden"] = false;
$col["default"] = "{col2}";
$cols[] = $col;

Ananda Theerthan answered 6 years ago

Thanks for that.. it works as expected..

Cristian Engelmann answered 5 years ago

I want to compare two data fields.
If “cost” > “pay” and “pay” != 0 then show message “the value is more then “+”pay” and I want to data field = 0.

How can I?

$col = array();
$col["title"] = "cost";
$col["name"] = "cost";
$col["width"] = "10";
$col["align"] = "right"; // this column is not editable
$col["search"] = false; // this column is not searchable
$cols[] = $col;

$col = array();
$col["title"] = "pay";
$col["name"] = "pay";
$col["width"] = "10";
$col["align"] = "right"; // this column is not editable
$col["search"] = false; // this column is not searchable
$col["editable"] = true;
$cols[] = $col;

# Customization of Action column width and other properties
$col = array();
$col["title"] = "Accion";
$col["name"] = "act";
$col["width"] = "20";
$cols[] = $col;

Thank you again

Abu Ghufran answered 5 years ago

You can put this check in JS validation form.
Refer demos/editing/js-validation-form.php in package archive,

Your Answer

14 + 19 =

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!