Announcement

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

    [BUG]: DisplayField does not work as expected, various problems (example included)

    Version: v11.0p_2017-01-16/LGPL

    [Problem]:
    When I specify a displayField and a foreignDisplayField on a SelectItem with an OptionDataSource, it should first try to find the displayValue from the current record using DisplayField (according to the docs), but it actually triggers a fetchMissingValues call on the optionDataSource. If you add fetchMissingValues:false, the id is shown instead of the displayValue.

    [Why is this a problem]:
    An extra fetch is triggered for the missing displayvalue, but this value is already in the current (form) record.

    Update: added some additional problems and test cases in the example

    [Example]:
    Code:
    isc.DataSource.create({
       ID:"options",
       clientOnly:true,
       fields:[{name:"id",primaryKey:true,type:'integer'},{name:"name",type:'text'}],
       cacheData:[{id:1,name:'First'},{id:2,name:'Second'},{id:3,name:'Third'}]
    })
    isc.DataSource.create({
       ID:"tests",
       clientOnly:true,
       fields:[{name:"id",primaryKey:true,type:'integer'},{name:"expectedResult",type:'text'},{name:"option",type:"integer"},{name:'optionValue',hidden:true,type:'text'}]
    })
    
    isc.ValuesManager.create({
      ID:'vmgr',
      dataSource:'tests'
    })
    
    isc.DynamicForm.create({
        ID:'editor',
        valuesManager:'vmgr',
        fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',optionDataSource:"options",valueField:'id',foreignDisplayField:'name',displayField:'optionValue'}]
    })
    
    vmgr.editRecord({
       id:1,
       expectedResult:'Field "option" should display: "First (Not displayed, but should be shown)" instead of "First"',
       option:1,
       optionValue:'First (Not displayed, but should be shown)'
    })
    
    isc.ValuesManager.create({
      ID:'vmgr2',
      dataSource:'tests'
    })
    isc.DynamicForm.create({
        ID:'editor2',
        fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',optionDataSource:"options",valueField:'id',foreignDisplayField:'name',fetchMissingValues:false,autoFetchData:false}],
        valuesManager:'vmgr2'
    })
    
    vmgr2.editRecord({
       id:2,
       expectedResult:'To display id value (fetchMissingValues=false && autoFetchData=false)',
       option:2,
       optionValue:'Second (Not displayed, but should be shown)'
    })
    
    isc.ValuesManager.create({
      ID:'vmgr3',
      dataSource:'tests'
    })
    isc.DynamicForm.create({
        ID:'editor3',
        fields:[{name:'id'},{name:'expectedResult',width:600},{name:'option',displayField:'optionValue'}],
        valuesManager:'vmgr3'
    })
    
    vmgr3.editRecord({
       id:3,
    expectedResult:'Field "option" should display: "Third (Not displayed, but should be shown)" instead of "3"',
       option:3,
       optionValue:'Third (Not displayed, but should be shown)'
    })
    
    isc.VLayout.create({
      members:[editor,editor2,editor3]
    })
    Last edited by dencel; 7 Mar 2017, 05:19.

    #2
    Hi dencel,

    I don't know if this is relevant to your bug, but you left out type information for your fields in the clientOnly-DataSource. This is required per docs.

    Isomorphic: This might be related.

    Best regards
    Blama (not the OP)

    Comment


      #3
      Hi Blama,

      No it's not relevant to my bug. I've added the type information as you requested. Btw: you can simply paste the example in http://www.smartclient.com/smartclie...html#helloForm and see the behaviour.

      Comment


        #4
        Any update on this? Is this regarded as a bug or invalid use of the api?

        Comment


          #5
          Hi Dencel,
          Sorry for the delay in response here.
          This is not exactly a bug, but it is something which has led to confusion in the past.
          The discussion here goes over this in some detail.
          Our original response / suggestion of using valueMaps may be applicable to you:
          http://forums.smartclient.com/forum/...888#post240888
          Alternatively you may be relying on a database join, in which case our comments on includeFrom may be more relevant:
          http://forums.smartclient.com/forum/...101#post241101
          And this post describes some changes we've made in the upcoming release (SmartClient 11.1 and SmartGWT 6.1), including the introduction of a property "useLocalDisplayFieldValue" to explicitly control whether or not to make use of a display-field value from the form's current edit-record:
          http://forums.smartclient.com/forum/...367#post241367

          Hopefully this answers your question and gives you enough to get things working. If you have further questions, feel free to follow up

          Regards
          Isomorphic Software



          Comment

          Working...
          X