| Support Center

(Back to Website)

Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

numeric formatter in add and edit dialogs or inline editing during adding or editing

toki Mar 29, 2013 02:20PM PKT

Hi,

$col["formatter"] = "number";

Yes, it works perfect in phpgrid for formatting numeric columns with thousandseparator and decimalseparator.

My question is that how is it possible to use numeric formatter in add and edit dialogs or online editing when during adding and editing?

Thank you very much.

Regars...

Up 12 rated Down
Abu Ghufran Mar 29, 2013 11:36PM PKT PHP Grid - Support Center Engineer
Yes, you can have it, but you might need to pass the posted data through some filter. For e.g. on_insert and on_update, and make it compatible with database.

// when 3rd argument true, fnuction will act as a filter for data.
$e["on_update"] = array("update_filter", null, true);

function update_filter(&$data)
{
$data["params"]["num"] = str_replace(",","",$data["params"]["num"]);
}
Up 0 rated Down
toki Mar 30, 2013 02:55AM PKT
Hi Abu,

I tried but I could not.

what I tried to do ;

$opt["caption"] = "Clients Data";
$g->set_options($opt);

## ------------------ ##
## SERVER SIDE EVENTS ##
## ------------------ ##

// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
$e["on_insert"] = array("add_client", null, false);
$e["on_update"] = array("update_client", null, false);

// ********* when 3rd argument true, fnuction will act as a filter for data.
$e["on_update"] = array("update_filter", null, true);


$e["on_delete"] = array("delete_client", null, true);
# $e["on_after_insert"] = array("after_insert", null, true); // return last inserted id for further working
$e["on_data_display"] = array("filter_display", null, true);

## ------------------ ##
## CLIENT SIDE EVENTS ##
## ------------------ ##
// just set the JS function name (should exist)
$e["js_on_select_row"] = "do_onselect"; // BAK BODY İÇİNDE BU FONKSİYON VAR....

$g->set_events($e);

// br=my DECIMAL column name, Is it true?

function update_filter($data)
{
$data["params"]["br"] = str_replace(",","",$data["params"]["br"]);
}

Can you help me please ?

Thank you
Up 0 rated Down
Abu Ghufran Apr 02, 2013 12:26AM PKT PHP Grid - Support Center Engineer
I have sent you a sample code for it.

$e["on_update"] = array("update_client", null, true);
$grid->set_events($e);

function update_client($data)
{
$data["params"]["name"] = str_replace(",","",$data["params"]["name"]);
}

Your code also looks fine, but may need some debugging. You can put die() or echo calls in this event handler and check it via firefox->firebug->net->xhr call response.
Up -2 rated Down
toki Apr 06, 2013 03:05AM PKT
Hi Abu,

Thank you very much for your sample code. It gives me some idea. But I could not do it yet.

Thank you very much for your help.

Regards.

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Contact Us

https://d218iqt4mo6adh.cloudfront.net/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete