Permalink
Browse files

More fixes for the new select option delimiter

  • Loading branch information...
1 parent 3d7a543 commit 0afdf107254f670bc16673868f8cc663aa978c9a @tonytomov committed Jan 25, 2012
Showing with 21 additions and 13 deletions.
  1. +1 −1 js/grid.common.js
  2. +11 −7 js/grid.custom.js
  3. +9 −5 js/jquery.fmatter.js
View
@@ -399,7 +399,7 @@ $.extend($.jgrid,{
for(i=0; i<so.length;i++){
sv = so[i].split(sep);
if(sv.length > 2 ) {
- sv[1] = $.map(sv,function(n,ii){if(ii>0) { return n;} }).join(":");
+ sv[1] = $.map(sv,function(n,ii){if(ii>0) { return n;} }).join(sep);
}
ov = document.createElement("option");
ov.setAttribute("role","option");
View
@@ -341,21 +341,25 @@ $.jgrid.extend({
}
}, $.jgrid.ajaxOptions, $t.p.ajaxSelectOptions || {} ));
} else {
- var oSv;
- if(cm.searchoptions && cm.searchoptions.value) {
- oSv = cm.searchoptions.value;
- } else if(cm.editoptions && cm.editoptions.value) {
- oSv = cm.editoptions.value;
+ var oSv, sep, delim;
+ if(cm.searchoptions) {
+ oSv = cm.searchoptions.value === undefined ? "" : cm.searchoptions.value;
+ sep = cm.searchoptions.separator === undefined ? ":" : cm.searchoptions.separator;
+ delim = cm.searchoptions.delimiter === undefined ? ";" : cm.searchoptions.delimiter;
+ } else if(cm.editoptions) {
+ oSv = cm.editoptions.value === undefined ? "" : cm.editoptions.value;
+ sep = cm.editoptions.separator === undefined ? ":" : cm.editoptions.separator;
+ delim = cm.editoptions.delimiter === undefined ? ";" : cm.editoptions.delimiter;
}
if (oSv) {
var elem = document.createElement("select");
elem.style.width = "100%";
$(elem).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
var so, sv, ov;
if(typeof oSv === "string") {
- so = oSv.split(";");
+ so = oSv.split(delim);
for(var k=0; k<so.length;k++){
- sv = so[k].split(":");
+ sv = so[k].split(sep);
ov = document.createElement("option");
ov.value = sv[0]; ov.innerHTML = sv[1];
elem.appendChild(ov);
View
@@ -351,6 +351,7 @@
if(!$.fmatter.isUndefined(opts.colModel.formatoptions)){
oSelect= opts.colModel.formatoptions.value;
sep = opts.colModel.formatoptions.separator === undefined ? ":" : opts.colModel.formatoptions.separator;
+ delim = opts.colModel.formatoptions.delimiter === undefined ? ";" : opts.colModel.formatoptions.delimiter;
} else if(!$.fmatter.isUndefined(opts.colModel.editoptions)){
oSelect= opts.colModel.editoptions.value;
sep = opts.colModel.editoptions.separator === undefined ? ":" : opts.colModel.editoptions.separator;
@@ -366,7 +367,7 @@
for(var i=0; i<so.length;i++){
sv = so[i].split(sep);
if(sv.length > 2 ) {
- sv[1] = jQuery.map(sv,function(n,i){if(i>0) {return n;}}).join(":");
+ sv[1] = jQuery.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
}
if(msl) {
if(jQuery.inArray(sv[0],scell)>-1) {
@@ -537,18 +538,21 @@
var ret = [];
var cell = $(cellval).text();
if(cnt===true) {return cell;}
- var op = $.extend({}, !$.fmatter.isUndefined(options.colModel.formatoptions) ? options.colModel.formatoptions: options.colModel.editoptions);
+ var op = $.extend({}, !$.fmatter.isUndefined(options.colModel.formatoptions) ? options.colModel.formatoptions: options.colModel.editoptions),
+ sep = op.colModel.editoptions.separator === undefined ? ":" : op.colModel.editoptions.separator,
+ delim = op.colModel.editoptions.delimiter === undefined ? ";" : op.colModel.editoptions.delimiter;
+
if(op.value){
var oSelect = op.value,
msl = op.multiple === true ? true : false,
scell = [], sv;
if(msl) {scell = cell.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
if ($.fmatter.isString(oSelect)) {
- var so = oSelect.split(";"), j=0;
+ var so = oSelect.split(delim), j=0;
for(var i=0; i<so.length;i++){
- sv = so[i].split(":");
+ sv = so[i].split(sep);
if(sv.length > 2 ) {
- sv[1] = jQuery.map(sv,function(n,i){if(i>0) {return n;}}).join(":");
+ sv[1] = jQuery.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
}
if(msl) {
if(jQuery.inArray(sv[1],scell)>-1) {

0 comments on commit 0afdf10

Please sign in to comment.