I cant get this to Work :
@(Html.Infragistics().Grid<intranet.mvc5.Models.m_Fravær>
().ID("grdFravaer")
.PrimaryKey("ID").ShowHeader(true)
.Columns(column =>
{
column.For(x => x.ID).Width("45px").HeaderText("RET");
column.For(x => x.ID2).Width("45px").HeaderText("SLET");
column.For(x => x.Fra_Dato).Width("90px").HeaderText("FRA").Format("dd-MM-yyyy");
column.For(x => x.Til_Dato).Width("90px").HeaderText("TIL").Format("dd-MM-yyyy");
column.For(x => x.Navn).Width("180px").HeaderText("NAVN");
column.For(x => x.Besked).Width("auto").HeaderText("BESKED");
column.For(x => x.Modtaget).Width("115px").HeaderText("MODTAGET").Format("dd-MM-yyyy HH:mm");
column.For(x => x.Ejer).Width("85px").HeaderText("AF");
column.For(x => x.DenneUge).Hidden(true);
})
.AutoGenerateColumns(false)
.AutoAdjustHeight(true)
.Width("100%")
.RowTemplate("<tr class={{if ${DenneUge} == 'J' }} 'DenneUgeFarve' {{else}} 'AndreUgerFarve'{{/if}}><td>{{if parseInt(${ID}) > -1}}<a href='/Fravaer/Ret/${ID}'><img src='/Content/images/Modify.png' width='14' /></a>{{/if}}</td><td>{{if parseInt(${ID}) > -1}}<a href='/Fravaer/Slet/${ID2}'><img src='/Content/images/erase.png' width='14' /></a>{{/if}}</td><td>${Fra_Dato}</td><td>${Til_Dato}</td><td>${Navn}</td><td>${Besked}</td><td>${Modtaget}</td><td>${Ejer}</td><td>${DenneUge}</td></tr>")
.DataSourceUrl(Url.Action("Hent_Fravær"))
.DataBind()
.Render()
)
I get this error
Unhandled exception at line 240, column 6483 in http://localhost:54144/Scripts/IG/infragistics.core.js
0x800a138f - Der opstod en JavaScript-kørselsfejl: Egenskaben 'start' kan ikke hentes for reference, der er udefineret eller null
Instead of using a method to convert the value into an integer, can you set the datatype of ID to "number"?column.For(x => x.ID).Width("45px").DataType("number").HeaderText("RET");
Let the framework do the conversion for you.
This is not the problem
this line give me the error
class={{if ${DenneUge} == 'J' }} 'DenneUgeFarve' {{else}} 'AndreUgerFarve'{{/if}}
I tried this
<style>
.DenneUgeFarve {
background-color: #A5D8DE;
}
.AndreUgerFarve {
background-color: #DEF0F2;
</style>
.RowTemplate("<tr class='DenneUgeFarve'><td>{{if ${ID} > -1}}<a href='/Fravaer/Ret/${ID}'><img src='/Content/images/Modify.png' width='14' /></a>{{/if}}</td><td>{{if ${ID} > -1}}<a href='/Fravaer/Slet/${ID2}'><img src='/Content/images/erase.png' width='14' /></a>{{/if}}</td><td>${Fra_Dato}</td><td>${Til_Dato}</td><td>${Navn}</td><td>${Besked}</td><td>${Modtaget}</td><td>${Ejer}</td></tr>")
But this only change background color on the first column
<tr data-id="2788"><td class="DenneUgeFarve" <tr="">><a href="/Fravaer/Ret/2788"><img width="14" src="/Content/images/Modify.png"></a></td><td><a href="/Fravaer/Slet/2788"><img width="14" src="/Content/images/erase.png"></a></td><td>05-12-2013</td><td>18-12-2013</td><td>jørn h andersen</td><td></td><td>25-11-2013 00:00</td><td>JA</td></tr>
Hello Christian,
We have a known issue "Setting attributes to table rows with a row template not possible".
You should add class attribute to each TD in the rowTemplate. Here is an example:
rowTemplate: "<tr><td{{if ${ProductID} % 2 == 0}} class='error'>{{else}}>{{/if}}" +
"${ProductID}</td>"+
"<td{{if ${ProductID} % 2 == 0}} class='error'>{{else}}>{{/if}}${Name}</td>"+
"<td{{if ${ProductID} % 2 == 0}} class='error'>{{else}}>{{/if}}${ProductNumber}</td></tr>",
Attached you can find a complete sample.
Best regards, Martin Pavlov Infragistics, Inc.
I am following up to see if you have any further questions concerning this matter.
Please let me know if I may be of further assistance with this matter.