Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Pass column name to custom_func for validation
27/02/2013
22:21
Avatar
SeanP
Member
Members
Forum Posts: 4
Member Since:
27/02/2013
sp_UserOfflineSmall Offline

The checkValues function currently passes the value and column label, but in my case I have several columns with the same label, but different names and ids, which need to validate against another column depending on the name of the column to be validated. So I propose the following change to checkValues to pass the column name in addition to the column label:

 	checkValues : function(val, valref,g, customobject, nam) {
-		var edtrul,i, nm, dft, len;
+		var edtrul,i, nm, dft, len, colnm;
 		if(customobject === undefined) {
 			if(typeof valref==='string'){
 				for( i =0, len=g.p.colModel.length;i<len; i++){
@@ -6093,6 +6093,7 @@
 		}
 		if(edtrul) {
 			if(!nm) { nm = g.p.colNames[valref]; }
+            colnm = g.p.colModel[valref].name;
 			if(edtrul.required === true) {
 				if( $.jgrid.isEmpty(val) )  { return [false,nm+": "+$.jgrid.edit.msg.required,""]; }
 			}
@@ -6147,7 +6148,7 @@
 			if(edtrul.custom === true) {
 				if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
 					if($.isFunction(edtrul.custom_func)) {
-						var ret = edtrul.custom_func.call(g,val,nm);
+						var ret = edtrul.custom_func.call(g,val,nm, colnm);
 						return $.isArray(ret) ? ret : [false,$.jgrid.edit.msg.customarray,""];
 					}
 					return [false,$.jgrid.edit.msg.customfcheck,""];
01/03/2013
09:51
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thanks. Good idea, but I want to add not so much code and do more things.

So I added the valref as parameter to the custom_func.

In your code your code to get the name from colmodel you just do

custom_func : function( val, label, colIndex) {

...

var colnm = this.p.colModel[colIndex].name;

...

}

Hope this is more usefull.

Thanks

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

01/03/2013
18:22
Avatar
SeanP
Member
Members
Forum Posts: 4
Member Since:
27/02/2013
sp_UserOfflineSmall Offline

Thanks, I'll change my code to reflect that.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
45 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

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information