Number formatter

QuestionsNumber formatter
Lynn Lollar asked 6 years ago

How can I format a 10 digit number into a (931) 111-4444

Thanks

1 Answers
Abu Ghufran answered 6 years ago

For formatting at display mode … you need to use custom formatter function.

e.g. formatter of percentage display

$col["formatter"] = "function(cellval,options,rowdata){ return cellval*100+'%'; }";
$col["unformat"] = "function(cellval,options,cell){ return cellval.replace('%','')/100; }";

For formatting at edit mode …. refer this faq.

Q) How to mask a field, for example like this: (NN) NNNN-NNNN ? N stands for number.

You can however, pick input jquery id selectors, and linking them using any lib.

for e.g. http://igorescobar.github.io/jQuery-Mask-Plugin/

Most likely, you would need to code it after show form event. for e.g. if ID of element id "date"

$grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#total").mask("0,000.00"); }';
$grid["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#tatal").mask("0,000.00"); }';
$g->set_options($grid);

Your Answer

1 + 16 =

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?