Hi, I’m trying to display the row index inside a grid column, but I’m unable to execute a calculation based on the index like:
<td>${parseInt($i) + 1}</td>
The calculation is not executed and rendered as: ${parseInt(0) + 1}
Does the templating engine support inline calculations / functions?
If I only use the $i directive each row’s index comes out as 0, and is not incremented?
Thanks in advanced.
Christoff
Hi Christoff,
I am glad binding to iggridrendered helped. As for the indexing, it's not by design, which is why I opened that support case I mentioned in one of my earlier posts. An internal bug item will be created and linked to it so the issue can be investigated and fixed for the next service releases. I think you can workaround it by setting the rowNumberingSeed to -1 without causing any undesired behavior.
Thank you again for using Infragistics forums!
Best regards,
Stamen Stoychev
Hi Stamen
Thanks allot you’re a life saver. Binding to the iggridrendered event did the trick for selecting the desired row. But is there still something up with the index’s numbering or is that by design?
Thanks Christoff
Hello again,
After some investigation it turned out the culprit is a known bug that represents itself with the dataRendered event firing too early when there are hidden columns defined. A fix for this bug has already been implemented and will be released with the next service releases for both the 11.2 and 12.1 version.
To accomplish the task at hand I suggest you bind to the rendered event instead:
$("#historyTable").live("iggridrendered", function (event, args) {
Hope this helps!
Hi as requested the grid script.
<table id="historyTable"></table> <div id="historyTaskContainer"></div> <script id="historyRowTemplate" type="text/x-jquery-tmpl"> <tr> <td>${Id}</td> <td>${DisplayName} (#<span>${Id}</span>)</td> <td>${Originator.DisplayName}</td> <td>${FinalParticipant.DisplayName}</td> <td>${DateOfCompletion}</td> </tr> </script> <script> $(function () { $("#historyTable").igGrid({ dataSource: new $.ig.JSONPDataSource({ dataSource: "@base.Url.Action("History", controller, new { Id = UrlParameter.Optional, ActivityId = base.Model.Id })", type: "remoteUrl", responseDataKey: "Results" }), autoGenerateColumns : false, alternateRowStyles : true, showHeader : true, showFooter : false, rowTemplate : $("#historyRowTemplate").html().replace(/(\r\n|\n|\r)/gm,""), columns: [ { headerText: "Id", key: "Id", dataType: "number", hidden:true }, { headerText: "Description", key: "DisplayName", dataType: "string" }, { headerText: "From", key: "Originator" }, { headerText: "Participant", key: "FinalParticipant" }, { headerText: "Completed", key: "DateOfCompletion", dataType: "date", format: "dateTime", formatter: function (date) { return Globalize.format( new Date(date.getTime() + (new Date().getTimezoneOffset() * -60000)), $.ig.regional.defaults.dateTimePattern); } } ], features: [ { name: 'Sorting', type: 'local' }, { name: 'RowSelectors', enableRowNumbering: true, // Setting the seed to 0 result in the index to start from 2!!!!! rowNumberingSeed: 0, requireSelection: true }, { name: 'Selection', mode: 'row', multipleSelection: false, rowSelectionChanging: function (e, args) { var dataView = $('#historyTable').data('igGrid').dataSource.dataView(); if(dataView.length > 0){ var id = dataView[args.row.index].Id; $("#historyTaskContainer") .load("@base.Url.Action("Task", controller, new {Id = UrlParameter.Optional, View = "_HistoryTask" })" + "&id=" + id); } } } ] }); $("#historyTable").live("iggriddatarendered", function (event, args) { var dataView = $('#historyTable').data('igGrid').dataSource.dataView(); if(dataView.length > 0){ // Setting the selected row on render has no affect. $('#historyTable').igGridSelection('selectRow', dataView.length -1); $("#historyTaskContainer").load("@base.Url.Action("Task", controller, new { Id = UrlParameter.Optional, View = "_HistoryTask" })" + "&id=" + dataView[dataView.length-1].Id); } }); }); </script>
Yes, it wouldn't work if you already initialize on a table. The "xxx_table" element is not created at all in this case.
Could you please provide me with some more information about the grid? A list of features being used, the settings for the Selection feature and whether the grid uses templating should suffice. I am asking because I can't reproduce the issue with the few basic samples I tried on.
Thanks,