I’m trying to get my tableviews to sort correctly. I’ve added a onSort method to my form to handle sorting my columns:
function onSort(dataProviderID, asc, event)
{
if(!dataProviderID) return;
switch (dataProviderID) {
case 'call_fullnumber':
foundset.sort('call_nr '+ (asc ? ' asc' : ' desc')+','+dataProviderID + (asc ? ' asc' : ' desc'));
break;
case 'call_respempid':
foundset.sort('calls_to_employees$resp.emp_firstname '+ (asc ? ' asc' : ' desc')+', calls_to_employees$resp.emp_lastname' + (asc ? ' asc' : ' desc'));
break;
case 'call_principalid':
foundset.sort('calls_to_principals.principal_name '+ (asc ? ' asc' : ' desc'));
break;
case "call_subcontractorid":
foundset.sort('calls_to_subcontractors.subcontractor_name '+ (asc ? ' asc' : ' desc'));
break;
case 'call_state':
case 'call_statetxt':
foundset.sort('datfin ' + (asc ? ' asc' : ' desc')+', call_deadline ' + (asc ? ' asc' : ' desc'), false);
break;
case 'call_code':
foundset.sort(sortCallCode)
break;
default:
foundset.sort(dataProviderID + (asc ? ' asc' : ' desc'), false);
break;
}
}
These seem to work correcty except for the ‘call_code’ dataprovider. This field is linked to a valuelist and I tried added a sort function to hande the sort but it does only sort one way. And also the column does not receive the sort marker in the header (black triangle).
This is my valuelist sort function:
function sortCallCode(r1,r2) {
return valuelistSort(r1.call_code, r2.call_code, 'pronto_callcode');
}
/**
* @param {number} r1 first value
* @param {number} r2 second value
* @param {String} vl Valuelist name
* @return {Number}
*
* @properties={typeid:24,uuid:"E7619471-21ED-40A0-97CE-D49BF677624B"}
*/
function valuelistSort(r1,r2,vl) {
var o = 0;
var v1 = application.getValueListDisplayValue(vl,r1);
var v2 = application.getValueListDisplayValue(vl,r2);
if(v1==null) v1='';
if(v2==null) v2='';
if(v1 < v2) {
o = -1;
}else if (v1 > v2) {
o = 1;
}
return o;
}
any suggestions on what I’m doing wrong here?