Forum


00:22

20/08/2011

hi all,
I setup a custom element. Obviously, the custom_element function is designed to manage one custom html tag, but i used it to create three html tags that displays a credit card exp. date select block that looks like "[ MM ][V] / [ YY ][V]" in the add or edit form.
Here is the code:
//jqgrid colModel segment.
{name:'wp.ExpDate',…, edittype: 'custom', editoptions:{custom_element:customExpDateElement, custom_value:customExpDateValue}},
// jqgrid custom element(s) function.
function customExpDateElement(value, options){
var element = '<select date="ExpMM" name="wp.ExpMM" id="'+ options.id + '-ExpMM' +'" class="left ui-widget-content ui-corner-all" type="text" title="Select Card Expiration Month">'+ ExpDateSelectOptions('MM') +'</select>'+
'<span id="wp-ExpDate"> / </span>'+
'<select date="ExpYY" name="wp.ExpYY" id="'+ options.id + '-ExpYY' +'" class="center ui-widget-content ui-corner-all" type="text" title="Select Card Expiration Year" >'+ ExpDateSelectOptions('YY') +'</select>';
return element;
}
// jqgrid custom user value(s) function.
function customExpDateValue(element, operation, value){
var ExpMM = element[0].value;
var ExpYY = element[2].value;
return ExpMM + '/' + ExpYY;
}
It works great!
However, i have a few concerns…
1. With the custom element function, trying to append a string to the end of the options.id to make sure the id is unique for each select tag, it does not work. The id is always just options.id. It appears that jqgrid is simply replacing any id or name attribute i define with its own. While that is ok for a single custom element, it can be a problem when creating multiple tags within a single custom element function.
2. With the custom value function, how would the operation parameter be set to "set"?
Thanks.
Most Users Ever Online: 715
Currently Online:
167 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66