Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Display value Delimiter for ListGridField with optionDataSource and multiple:true

    I am using SmartClient_v82p_2012-05-08

    By default, when you have a ListGridField with multiple:true, the array of looked up display values is presented comma separated.

    The same applies to the blue edit values if they are displayed.

    I wanted to change the delimiter to <br/> to make the array display as a vertical list.

    I have the following ListGridField definition:

    Code:
    {
      optionDataSource:"schedulesDS",
      displayField:"name",
      valueField:"id",
      multiple:true,
    
      name:"schedules",
      title:"Schedules",
      formatCellValue:function(value,record) {
        if (isA.Array(value)) {
          value.toString = function() {return this.join("<br/>")}
        }
        return value;
      },
      canEdit:true
    }
    This works, both for the normal value and the edit value case, but it doesn't feel very robust. Can you suggest an alternative, such as a property that explicitly specifies the delimiter for multiple:true fields?

    Ideally I would like to have a property I can set for the emptyCellValue message, also.

    Code:
    formatCellValue:function(value,record) {
      if (isA.Array(value)) {
        if (value.length > 0)
          value.toString = function() {return this.join("<br/>")}
        else
          return "None";
      } else {
        if (!value) return "None";
      }
      return value;
    }
    The above code adds in the default message. The if (!value) is required to handle the case of when the editValue is "" rather than [].
    Last edited by Osirium1; 11 May 2012, 02:16.
Working...
X