Hello,
I am using MVC wrapper for building the grid. I am hooking the headerRendered event as follows:
$(gridId).igGrid({ headerRendered: function (evt, ui) {
//my logic goes here... } });
I am wondering why this event never fires, whats wrong?
Regards,
Arfan Baig
Hello Arfan,
This is not the correct way to bind to igGrid events when using MVC wrapper.
When using MVC wrapper you should use jQuery bind/live/delegate/on functions as described in Using Events in IgniteUI topic Bind to events after initialization section.
Here is an example code:
<script type="text/javascript"> $(function () { $(document).delegate("#grid1", "iggridheaderrendered", function (evt, ui) { //put your code here }); });</script>@(Html.Infragistics().Grid(Model).ID("grid1").AutoGenerateColumns(false).PrimaryKey("ProductID").Columns(col =>{ col.For(c => c.ProductID).HeaderText("ProductID").DataType("number"); col.For(c => c.Name).HeaderText("Name"); col.For(c => c.ProductNumber2).HeaderText("ProductNumber2"); col.For(c => c.ReleaseDate).HeaderText("ReleaseDate");}).DataBind().Render())
Hope this helps,Martin PavlovInfragistics, Inc.
Hello Martin,
Thanks for the detailed response.
I have binded the event as you suggested; but, I am still unable to witness the event firing. Am I missing something, can you please create a sample where this event is working correctly?
No problem, I don't need the sample anymore.
I also think the same, so I have marked that issue as resolved as well.
Hi Arfan,
I forgot to attach the sample. Sorry about that. I guess you don't need it anymore.
Also, I think the following post: http://ko.infragistics.com/community/forums/p/79484/401339.aspx#401339 has the same issue like the one we discussed in this forum thread.
Best regards,Martin PavlovInfragistics, Inc.
I think you forgot to attach the sample :)
However, finally, the event is working. The issue was the same you mentioned: " the JavaScript code for binding to the event should be placed before the igGrid MVC wrapper configuration."
Thank you again for your quick response.
Attached you can find complete sample. It is important to note that the JavaScript code for binding to the event should be placed before the igGrid MVC wrapper configuration.
In order to run the sample you should resolve Infragistics.Web.Mvc.dll reference.