Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Unable to set conditional row template
posted

I am trying to set conditional row template for my iggrid .Following is the code : 

$("#MyGrid").igGrid({
showHeader: true,
autoGenerateLayouts: false,
columns: [
{ headerText: "Id", key: "id", dataType: "string" , hidden:true },
{ headerText: "Code", key: "Code", dataType: "string" },
{ headerText: "Name", key: "Name", dataType: "string"},
{ headerText: "Country", key: "Country", dataType: "string"},
{ headerText: "Count", key: "Count", dataType: "string"}
],
responseDataKey: 'rows',
rowTemplate: "<tr>" +

"<td> {{if verifyCount(${Count}) == 1 }}<span class='criticalAttention'>${id}</span>{{elseif verifyCount(${Count}) == 2 }}<span class='Attention'>${id}{{/if}}" + "</td>" +

"<td>{{if verifyCount(${Count}) == 1 }}<span class='criticalAttention'>html Code</span>{{elseif verifyCount(${Count}) == 2}}<span class='Attention'>html Code{{/if}}" + "</td>" +

"<td>{{if (verifyCount(${Count}) == 1}}<span class='criticalAttention'>${Name}</span>{{elseif verifyCount(${Count}) == 2}}<span class='Attention'>${Name}{{/if}}" + "</td>" +

"<td>{{if (verifyCount(${Count}) == 1}}<span class='criticalAttention'>${Country}</span>{{elseif verifyCount(${Count}) == 2}}<span class='Attention'>${Country}{{/if}}" + "</td>" +

"<td>{{if((verifyCount(${Count}) == 1}}<span class='criticalAttention'>${Count}</span>{{elseif verifyCount(${Count}) == 2}}<span class='Attention'>${Count}</span>{{/if}}" + "</td>" +

"</tr>",

dataSource: '@Url.Action("action", "controller")',
features: [
{
name: "Paging",
type: "remote",
pageSize: 10,
recordCountKey: 'records'
} ,
{
name: "Sorting",
type: "remote"
},
{
name: "Tooltips",
columnSettings: [
{ columnKey: "Name", allowTooltips: true }
],
visibility: "overflow",
showDelay: 100,
hideDelay: 100
}

//--------------------------------//

I need to make some calculations on the count field and then change the bg colour of each row based on these calculations . Hence , I tried writing a js function callled verifyCount() which then calculates and returns either 1 or 2 and set the class accordingly. However there are multiple problems here,

1) the function is not identified.

2)the code field which actually an anchor tag is being rendered as a string rather then a url.

Please assist and let me know if you guys need any additional info.Thanks.