Thanks but I had understood I needed to use render to translate the value to the text. Here's what I have now as I'm making little progress:
{
title: 'DayOption',
editable: true, width: 200,
dataType: 'select',
editor: {
type: function (ui) { oa.editMultipleChoiceCell(ui, VPbHoptionsDayOption); },
getData: function (ui) {
return ui.$cell.find("select option:selected").text();
}
},
render: function (ui) { oa.RenderMultipleChoiceCell(ui, VPbHoptionsDayOption); }
},
//TODO CS 14.03 - displaying value rather than text in the grid
oa.editMultipleChoiceCell = function (ui, arr) {
oa.log('ParamGrid: Editing MultipleChoice Cell');
var $cell = ui.$cell;
var data = ui.data;
//this won't work with Pro API
//var cellData = $.trim(data[ui.rowIndx][ui.colIndx]);
var cellData = $.trim(ui.rowData[ui.column.dataIndx]);
var str = "";
for (var i = 0; i < arr.length; i++) {
var label = arr.label;
var value = arr.value;
//we are assuming the cell will contain the 'label' string rather than the value
//we need to make sure this is the case
if (cellData == label)
str += "<option value='" + value + "' selected='selected'>" + label + "</option>";
else
str += "<option value='" + value + "'>" + label + "</option>";
}
var $sel = $("<select style='width: 100%; height: 100%'>" + str + "</select>")
.appendTo($cell);
}
//we need to override the default render of a grid cell containing a multiselect so that it is the text/ label of a select rather than the value (as stored in the grid)
oa.RenderMultipleChoiceCell = function (ui, arr) {
var cellData = $.trim(ui.rowData[ui.column.dataIndx]);
for (var i = 0; i < arr.length; i++)
{
var label = arr.label;
var value = arr.value;
//we are assuming the cell will continue the 'label' string rather than the value
//we need to make sure this is the case
if (cellData == value)
//returning the corredt value but this is not rendering in the UI
return label;
}
return "";
}
var VPbHoptionsDayOption = [
{ label: 'Sat', value: 0 },
{ label: 'Sun', value: 1 },
{ label: 'Mon', value: 2 },
{ label: 'Tue', value: 3 },
{ label: 'Wed', value: 4 },
{ label: 'Thu', value: 5 },
{ label: 'Fri', value: 6 }];
Currently:
The grid is not rendering the text returned correctly by oa.RenderMultipleChoiceCell.
The default 'Enter' is not updating the value in the grid - it does nothing (GetData is hence not firing?)
Thanks in advance.