Announcement

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

    StaticTextItem with visibleWhen is visible when predicate is false

    Hi, im using SmartClient version v11.0p_2016-04-12/EVAL Deployment
    I have a DynamicForm which contains an item defined in this way:

    {
    ID: "cantiere_anagrafica_ct_data",
    title: " ",
    titleColSpan: 10,
    colSpan: 40,
    width: 640,
    visibleWhen : {
    _constructor : "AdvancedCriteria",
    operator : "and",
    criteria : [{
    fieldName : "g0016",
    operator : "equals",
    value : true
    }]
    },
    type: 'text',
    editorType: 'StaticTextItem',
    defaultValue: '<span class="section_header" style="text-align:center;">DATI DI CONTATTO</span>',
    showTitle: true,
    canEdit: false,
    startRow:true
    }

    it is a StaticTextItem that needs to be shown only when field g0016 in the form record is true. The data I have in the form shows field g0016 to be false:

    {
    valuta:"S0018|0",
    priorita:50,
    g0032:false,
    g0033:true,
    g0030:false,
    g0031:false,
    importoOrdine:47.85,
    pesoLordo:0.52000,
    condizionePagamento:"S0018AG|126",
    g0034:true,
    dataOrdine: Date.parseServerDate(2016, 2, 31),
    sedeEmissione_dsc:"001 SEDE OPERATIVA",
    sconto:0.00,
    wflStatus:"Evaso",
    stringaPreventivi:"",
    anagraficaCli_ggRitardoPagamento:0,
    state:1,
    cliente_dsc:"1271 ATMOSPHERE SRL 03220530368 03220530368",
    valuta_dsc:"Euro",
    sconto2:0.00,
    clienteAK:"1271",
    peso:0.44,
    sconto3:0.00,
    sconto4:0.00,
    sconto5:0.00,
    "this":"Evaso",
    g0003:false,
    g0004:false,
    g0001:false,
    g0002:false,
    g0007:true,
    g0008:false,
    dataConsegnaRich: Date.parseServerDate(2016, 3, 8),
    g0005:false,
    g0006:true,
    valoreCostoOrario:0.00,
    cliente:"S0018|19837|1",
    flagDestinazioneSpot:false,
    costoImballo:0.00,
    cliente_indirizzoFormattatoHtml:"VIA L.MURATORI,1<br />41012 Carpi (MO)",
    contatti:"<div><span class="contatti"><img src="images/icons/building.png" title="Contatto principale"> : </span><span class="contatti"><img src="images/icons/telephone.png"> 059-684040 o 320-5586212</span> <span class="contatti"><img src="images/icons/printer_empty.png"> 0524/201057 Fidenza</span> <span class="contatti"><img src="images/icons/email.png"> gianmarco@atmosphereonline.it</span> </div>",
    magazzino_dsc:"SEDE A.G.C. SRL",
    condizionePagamento_dsc:"RIBA 30 GG FM ESCL.MESE 8/12 DATA POST 10",
    cantiere_anagrafica_contattoAziendale_flagSpedizione:false,
    importoOrdineIvato:58.38,
    g0010:false,
    g0011:false,
    tipoOrdine:"V",
    deletable:false,
    g0014:false,
    g0015:false,
    g0012:false,
    g0013:false,
    g0018:false,
    g0019:false,
    g0016:false,
    dataConsegnaConf: Date.parseServerDate(2016, 3, 8),
    g0017:false,
    valoreCentriCosto:0.00,
    key:"S0018AG|16/00536",
    cliente_anagraficaId_contattoAziendale_descrizioneCompattaHtml:"<nobr>Telefono: <b>059-684040</b></nobr>, <nobr>Telefono: <b>320-5586212</b></nobr>, <nobr>Fax: <b>0524/201057 Fidenza</b></nobr>, <nobr>Email: <b>gianmarco@atmosphereonline.it</b></nobr>",
    g0021:false,
    g0022:false,
    editable:false,
    numeroOrdine:"16/00536",
    g0020:false,
    g0025:false,
    dataConferma: Date.parseServerDate(2016, 2, 31),
    importoOmaggi:0.00,
    g0026:false,
    g0023:true,
    cantiere_anagrafica_contattoAziendale_flagCommerciale:false,
    g0024:false,
    g0029:true,
    subappalto:false,
    sedeEmissione:"S0018AG|001",
    g0027:false,
    g0028:false,
    magazzino:"S0018AG|SEDE",
    cantiere_anagrafica_contattoAziendale_flagTecnico:false,
    cantiere_anagrafica_contattoAziendale_flagAmministrazione:false,
    trasportoPct:0.00,
    trasporto:0.00,
    defaultDescription:"16/00536 del 31/03/2016: ATMOSPHERE SRL"
    }

    I had this kind of problem with other two fields which were bound to the same data source value (same name). I have the need to display them in a mutually exclusive manner in different positions in the form with different prompts. In the docs I see that it is not possible to have two form fields bound to the same value (same name) so I removed the duplicates and arranged things differently.
    In the case of the StaticTextItem above it has no name (it is "static" in the real sense...) and the form contains other items of this kind (static with no name). May this cause the visibility problem like in the other cases?

    Thank you.

    #2
    Hello, please post a test case, for example it's not clear if you have a field with name 'g0016' declared in your form, or in a dataSource bound to your form?

    Comment


      #3
      for example, if you run this test case, it seems to work. Is it consistent with your use case?
      Code:
      isc.DynamicForm.create({
          ID:"formUS", dataSource:"countryDS",
          items:[
            {name:"countryName"},
            {
              title:"static item", editorType: 'StaticTextItem',defaultValue: '<span class="section_header" style="text-align:center;">DATI DI CONTATTO</span>',
              visibleWhen:{_constructor:"AdvancedCriteria",operator:"and",
                criteria:[
                  {fieldName:"countryCode", operator:"equals", value:'US'}
                ]
              }
            }
         ]
      }).fetchData({countryCode:"US"})
      
      isc.DynamicForm.create({
          ID:"formIT", dataSource:"countryDS",top:100,
          items:[
            {name:"countryName"},
            {
              title:"static item", editorType: 'StaticTextItem',defaultValue: '<span class="section_header" style="text-align:center;">DATI DI CONTATTO</span>',
              visibleWhen:{_constructor:"AdvancedCriteria",operator:"and",
                criteria:[
                  {fieldName:"countryCode", operator:"equals", value:'US'}
                ]
              }
            }
         ]
      }).fetchData({countryCode:"IT"})

      Comment


        #4
        This seems to show the problem:

        isc.DynamicForm
        .create(
        {
        ID : "formUS",
        dataSource : "countryDS",
        readOnlyDisplay: "static",
        items : [
        {
        name : "countryName"
        },
        {
        title : "static item",
        editorType : 'StaticTextItem',
        defaultValue : '<span class="section_header" style="text-align:center;">DATI DI CONTATTO</span>',
        visibleWhen : {
        _constructor : "AdvancedCriteria",
        operator : "and",
        criteria : [ {
        fieldName : "countryCode",
        operator : "equals",
        value : 'US'
        } ]
        }
        },
        {
        title : "static item",
        editorType : 'StaticTextItem',
        defaultValue : '<span class="section_header" style="text-align:center;">DATI DI CONTATTO</span>',
        visibleWhen : {
        _constructor : "AdvancedCriteria",
        operator : "and",
        criteria : [ {
        fieldName : "countryCode",
        operator : "equals",
        value : 'US'
        } ]
        }
        }]
        }).fetchData({
        countryCode : "US"
        })

        Comment


          #5
          Sorry, but I don't understand. This is what I see with your test case:
          Click image for larger version

Name:	814424624_4936954996042193262.jpg
Views:	188
Size:	30.0 KB
ID:	238006
          isn't it correct?

          Comment


            #6
            Your post is correct but if there is no data for 'US' i get this result:
            Click image for larger version

Name:	Schermata del 2016-05-19 08-24-16.png
Views:	87
Size:	3.6 KB
ID:	238026


            the static item should not display. I didn't find a handy countryDS to add to my example so I tried without data, but anyway it is strange behavior. I'm new to SmartClient so I don't have set up a complete test environment yet. But this result is somehow consistent with my result in the larger application where I have multiple static items and one of them is displayed even if the test is false.

            Thank you for your help.
            Last edited by lveronese; 18 May 2016, 22:56.

            Comment


              #7
              ok, now I get it. You can run this test case in the showCase, for example in the editByRow sample:
              Code:
              isc.DynamicForm.create({
                  ID: "testForm",
                  dataSource: "countryDS",
                  readOnlyDisplay: "static",
                  items: [
                      {
                          name: "countryName"
                      },
                      {
                          title: "static item", //name:"st1",
                          editorType: 'StaticTextItem',
                          defaultValue: '<span class="section_header" style="text-align:center;">1st static text</span>',
                          visibleWhen: {
                              _constructor: "AdvancedCriteria",
                              operator: "and",
                              criteria: [{
                                  fieldName: "countryCode",
                                  operator: "equals",
                                  value: 'US'
                              }]
                          }
                      },
                      {
                          title: "static item", //name:"st2",
                          editorType: 'StaticTextItem',
                          defaultValue: '<span class="section_header" style="text-align:center;">2st static text</span>',
                          visibleWhen: {
                              _constructor: "AdvancedCriteria",
                              operator: "and",
                              criteria: [{
                                  fieldName: "countryCode",
                                  operator: "equals",
                                  value: 'US'
                              }]
                          }
                      }]
              }).fetchData({countryCode: "XX"})
              This shows the first StaticTextItem, even if the visibleWhen criteria isn't true.

              But if you uncomment the field names ('st1', 'st2'), it correctly hides both of them.

              But I don't know if this is a bug, we must wait for Isomorphic to say if the name is required for the items (for this use case).

              Comment


                #8
                We are making the "name" required for fields using the *When properties and documenting this requirement.

                Comment

                Working...
                X