Forum

November 2nd, 2014
A A A

Please consider registering
guest

Log In

Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Minimum search word length is 4 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
Topic RSS
new editrule regex
02/03/2011
16:09
OlegK
Germany
Member
Forum Posts: 1255
Member Since:
10/08/2009
Offline

Hello Tony!

I suggest very simple, but how I hope powerful editrule which could be used like

editrules:{regex:/^(foo|bar)$/, required:true}

or

var myNameEditRegEx = new RegExp("^(foo|bar)$");
...
editrules:{regex:myNameEditRegEx, required:true}

The corresponding change in the code of grid.common.js is simple. One can insert for example after the line 610 the following code fragment

if(Object.prototype.toString.call(edtrul.regex) === "[object RegExp]" || edtrul.regex instanceof RegExp) {
    if( !(rqfield === false && this.isEmpty(val)) ) {
        if(!edtrul.regex.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.regex + " " + edtrul.regex,""];}
    }

The rule for the sesting of the regex type I get from here.
I create the small demo which use regex:/^(foo|bar)$/ in the 'Client' column. Only two values will be valide "foo" and "bar". To go in the inline editing mode one should use double.click.

The most problem I see in $.jgrid.edit.msg.regex string which should be localized, but http://translate.google.com can do produce the first version of the translations.

By the way if would be very nice to modify lines 131-136 of grid.inlinedit.js to permit more customization of the validation errors.

I hope that regex could reduce the requirement to use of custom edit rule.

Best regards
Oleg

12/03/2011
12:38
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7721
Member Since:
30/10/2007
Offline

Oleg,

Thank you, but I think we have too much options - this not quite good.

Also this can be done easy with custom definition - if this can be done with the custom ruler definition then there is no need to write additional one.

Thank you anyway.

Kind Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site - trirand.net - by the very same guys that created jqGrid.
12/03/2011
13:06
OlegK
Germany
Member
Forum Posts: 1255
Member Since:
10/08/2009
Offline

Tony,

I agree with you that one can implement all with respect of custom verification rule, but the approach has some disadvantages.

If somebody is new in jqGrid he try to understand and use standard "predefined" features. It is good if he find out that formatter are exist. Then he look through the sandard verification rules and use one from there. Less then 30% of the user will use custom verification rule. So if you think from the point of view of new or not advanced users you will see that predefined regex formatter can has some advantages.

The feature is of course not very important, it is more cosmetical nature and just want to makes some thing to be used easier. I suggested this only after have seen some questions which can be easy solved by the formatter. It seems to me that at least 90% of custom verification rules do just test for regex.

Best regards
Oleg

12/03/2011
13:42
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7721
Member Since:
30/10/2007
Offline

Hello Oleg,

Maybe you are right, but user which can write regExp, can probably read that there is a custom fuction to do this  Laugh Wink

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site - trirand.net - by the very same guys that created jqGrid.
12/03/2011
22:46
OlegK
Germany
Member
Forum Posts: 1255
Member Since:
10/08/2009
Offline

I am not sure, Tony what is the best way. Probably you are right, but on the other side if you compare the problem with the same problem of the validation plugin you will see that many people find interesting the question. They also missing the regular expression validator and find it practical (24 reputation points for the question and 48 reputation points for the solution).

Best regards
Oleg

Forum Timezone: Europe/Sofia

Most Users Ever Online: 215

Currently Online:
82 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members: razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com, swathi

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information