- Home
- Forum
- ASP.NET MVC - EJ 2
- How compare Guid in Javascript engine template
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
- 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.
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>
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
}
]
},
- 7 Replies
- 2 Participants
-
PL Pio Luca Valvona
- Aug 12, 2021 12:12 PM UTC
- Sep 8, 2021 06:22 AM UTC