How compare Guid in Javascript engine template

Hi,

I use this code to hide or show block in grid detail template:

 ${if (IdTipoAccount === "86b22eec-5cc9-454e-92b3-5d01595e5965")}

                    <td>

                        ${if (AziendeTrasportatrici.length == 0)}

                        <span class="text-gray-800">@BloomApp_WEB.Resources.Rivenditori.AziendeTrasportatrici: </span> -

                        ${else}

                        <span class="text-gray-800">@BloomApp_WEB.Resources.Rivenditori.AziendeTrasportatrici: </span>

                        ${for (AziendaTrasportatrice of AziendeTrasportatrici)}

                        - ${AziendaTrasportatrice.RagioneSociale}

                        ${/for}

                        ${/if}

                    </td>

                    ${/if}


But also if IdTipoAccount is equal, block not show, it seems that the if returns false


7 Replies

SK Sujith Kumar Rajkumar Syncfusion Team August 13, 2021 09:56 AM UTC

Hi Pio, 
 
Greetings from Syncfusion support. 
 
Based on the query we could understand that you are facing problem when trying to use if condition in the detail template script tag. We checked this problem but unfortunately were unable to reproduce it from our end as the conditional statements were executed properly. You can check the below sample for reference, 
 
 
In this sample we have defined an ‘if’ condition so that the ‘LastName’ td element will be displayed only for the first detail row and it was displayed properly as shown in the below image, 
 
 
 
So please share us the following information to validate further on this, 
 
  • Please confirm us if the ‘IdTipoAccount’ column field checked in the detail template is available in the Grid data or defined as a separate variable.
  • Please ensure if the value of ‘IdTipoAccount’ equals that which is specified in the condition.
  • Grid code file.
  • Syncfusion package version used.
  • If possible share us a simple sample to replicate the problem or try reproducing it in the above provided sample.
 
Regards, 
Sujith R 



PL Pio Luca Valvona August 13, 2021 11:06 AM UTC

Hi Sujith,

Generally the "if" loop works in the template, it is the specific "if" that must compare a Guid that does not work. So my question is how do I compare the Guid type?


Regarding your questions:


- The field "IdTipoAccount " is not present in the grid, but is present in the Model sent to the grid.

- Surely the "IdTipoAccount" field and the value to be compared are identical.

- Grid code:

  @(Html.EJS().Grid<RivenditoriVM>("GridRivenditori").DataSource(dataManager => { dataManager.Json(((IEnumerable<RivenditoriVM>)Model).ToArray()).InsertUrl("InsRivenditori").UpdateUrl("UpdRivenditori").RemoveUrl("DelRivenditori").Adaptor("RemoteSaveAdaptor"); }).DetailTemplate("#detailtemplate").Load("load").ActionBegin("actionBegin").ActionComplete("actionComplete").ActionFailure("gridFailure").Columns(col =>

    {

        col.Field("IdRivenditore").IsPrimaryKey(true).Visible(false).Add();

        col.Field("RagioneSociale").AutoFit(true).Add();

        col.Field("PIVA").AutoFit(true).Add();

        col.Field("Citta").AutoFit(true).Add();

        col.Field("Telefono").AutoFit(true).Add();

        col.Field("Email").AutoFit(true).Add();

        col.AutoFit(true).Commands(commands).Add();


    }).AllowPaging().PageSettings(page => page.PageSizes(true)).AllowSorting().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).ShowDeleteConfirmDialog(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).Template("#dialogtemplate");}).Toolbar(new List<string>() { "Add","Edit","Delete", "Print", "Search" }).CommandClick("commandClick").Render())

    </div>



PL Pio Luca Valvona August 13, 2021 01:33 PM UTC

This is  json datasource of the grid:

 "json": ejs.data.DataUtil.parse.isJson([

  {

    "IdRivenditore": "47dde9a4-aa97-4a3b-973a-5e1c5b426ea2",

    "RagioneSociale": "33gg",

    "RappresentanteLegale": "",

    "Indirizzo": "retetet",

    "CAP": "12334",

    "Citta": "lytytyuu",

    "Nome": "test6",

    "Cognome": "test6",

    "PIVA": "5567",

    "Email": "",

    "Telefono": "4343",

    "Pec": "",

    "Note": "uuu",

    "IdListino": "78a6700a-89a6-4b1d-af33-22164e8f2c7d",

    "Listino": {

      "IdListino": "78a6700a-89a6-4b1d-af33-22164e8f2c7d",

      "Nome": "jui",

      "TipoVariazione": "Percentuale",

      "Valore": 0.00,

      "Deleted": false,

      "IdAziendaProduttrice": "f65f6557-5d3b-45d8-af6a-4acfe49a9446",

      "rowguid": "00000000-0000-0000-0000-000000000000",

      "ProdottiListini": [],

      "Rivenditori": [],

      "Utenti": null

    },

    "NotaAutista": null,

    "Deleted": false,

    "IdAziendaProduttrice": "f65f6557-5d3b-45d8-af6a-4acfe49a9446",

    "IdAziendeTrasportatrici": [

      "4c97cbeb-705d-4303-959f-34127c9f6370",

      "e798259f-99b8-4ffd-bc89-8de679321e5c",

      "ef5079a2-a067-45c4-bd3b-6ca3020680fa"

    ],

    "IdTipoAccount": "b5dab576-563a-42b8-a3bb-d84e3fd7d6fc",

    "AziendeTrasportatrici": [

      {

        "IdAziendaTrasportatrice": "4c97cbeb-705d-4303-959f-34127c9f6370",

        "RagioneSociale": "testat2",

        "Indirizzo": "trerr",

        "CAP": "78787",

        "Città": "gggt",

        "Email": "",

        "Telefono": "3456",

        "Deleted": false,

        "IdAziendaProduttrice": "f65f6557-5d3b-45d8-af6a-4acfe49a9446",

        "rowguid": "00000000-0000-0000-0000-000000000000",

        "Movimentazioni": [],

        "RivenditoreAziendeTrasportatrici": [],

        "StoricoMovimentazioni": [],

        "Utenti": null

      },

      {

        "IdAziendaTrasportatrice": "e798259f-99b8-4ffd-bc89-8de679321e5c",

        "RagioneSociale": "reg",

        "Indirizzo": "rrr6",

        "CAP": "23245",

        "Città": "hhhjj",

        "Email": "",

        "Telefono": "444443",

        "Deleted": false,

        "IdAziendaProduttrice": "f65f6557-5d3b-45d8-af6a-4acfe49a9446",

        "rowguid": "00000000-0000-0000-0000-000000000000",

        "Movimentazioni": [],

        "RivenditoreAziendeTrasportatrici": [],

        "StoricoMovimentazioni": [],

        "Utenti": null

      },

      {

        "IdAziendaTrasportatrice": "ef5079a2-a067-45c4-bd3b-6ca3020680fa",

        "RagioneSociale": "tetet",

        "Indirizzo": "33",

        "CAP": "66",

        "Città": "kk",

        "Email": "",

        "Telefono": "4343",

        "Deleted": false,

        "IdAziendaProduttrice": "f65f6557-5d3b-45d8-af6a-4acfe49a9446",

        "rowguid": "00000000-0000-0000-0000-000000000000",

        "Movimentazioni": [],

        "RivenditoreAziendeTrasportatrici": [],

        "StoricoMovimentazioni": [],

        "Utenti": null

      }

    ]

  },




SK Sujith Kumar Rajkumar Syncfusion Team August 16, 2021 12:56 PM UTC

Hi Pio, 

Thanks for sharing the details. We are currently validating your reported problem from our end and we will provide the further details on 18th August 2021. 

Until then your patience is appreciated. 

Regards, 
Sujith R 



SK Sujith Kumar Rajkumar Syncfusion Team August 18, 2021 02:09 PM UTC

Hi Pio, 
 
Thanks for your patience. 
 
We were able to reproduce the reported problem – “Template Compilation malfunctions when value have special character hyphen” from our end and have logged defect report for the same. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and will include the defect fix in our patch release scheduled on September 1st 2021. We appreciate your patience until then. 
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 
 
 
Regards, 
Sujith R 



SK Sujith Kumar Rajkumar Syncfusion Team September 1, 2021 12:31 PM UTC

Hi Pio, 
 
Due to some internal complexities we could not include the fix for this issue - Template Compilation malfunctions when value have special character hyphen as promised. We will include it in our upcoming weekly patch release scheduled to be rolled out by 8th September 2021. 
 
We apologize for the inconvenience caused and appreciate your patience until then. 
  
Regards, 
Sujith R 



SK Sujith Kumar Rajkumar Syncfusion Team September 8, 2021 06:22 AM UTC

Hi Pio, 
 
We are glad to announce that our Essential Javascript2 patch release (v19.2.60) has been rolled out successfully and in that release we have added the fix for the issue - Template Compilation malfunctions when value have special character hyphen”. So please update your packages to this version to include this fix. 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
 
Regards, 
Sujith R 


Loader.
Up arrow icon