I have a strange scenario. I have a combo box that can have multiple selections. My data may contain commas. I'm using Infragistics controls so i'm not in control of the separator. Now, my combo box values are "A*A" "A%A" and "A,A". If the user selects all 3 values, the result looks like this:
var arrValues = combo.igCombo('values'); //this retrieves the values
//arrValues contains this now: [A*A,A&A,A,A]
I'm parsing the values by a comma and you guessed it, i have an array of 4:
array[0] = 'A*A'
array[1] = 'A&A'
array[2] = 'A' //the parse split "A,A" into 2 values
array[3] = 'A'
array[2] should be
array[2] = 'A,A'
and array[3] shouldn't exist. I have a function i thought would work but it doesn't.
function getComboBoxValues(combo, delim, index) {
var arrValues = combo.igCombo('values');
var values = "";
$.each(arrValues, function (i, o) {
values += ((delim) ? o.split(delim)[index || 0] : o) + ',';
}
);
return values;
}
I call it like this:
var array = getComboBoxValues($('#mycombobox'), ',', 0);
How can i parse my string:
[A*A,A&A,A,A]
into an array so it will have only 3 values
array[0] = 'A*A'
array[1] = 'A&A'
array[2] = 'A,A'
Keep in mind, this may not be the order in which the string will be, so counting commas won't work.
My server side code is C#, so if this can be achieved in C#, please let me know. Thanks
"A%2CA"in combo-box, and decode it after split.