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

Questionsnumeric formatter in add and edit dialogs or inline editing during adding or editing
toki asked 12 years ago

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…

5 Answers
Abu Ghufran answered 12 years ago

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"]);
}

toki answered 12 years ago

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

Abu Ghufran answered 12 years ago

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.

toki answered 12 years ago

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.

Anand answered 8 years ago

Hi Abu,

I tried to validate the text field to avoid alphabets, only allow to enter numeric and double values. How to do this?

Hope to get the reply as soon as possible.

Thank you.

Your Answer

16 + 13 =

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?