Hi,
Just started using igGrid here, and was wondering what would be the best approach to show a button for each row of data in igGrid ? for instance, I want to have a 'Copy' button for each row of data.
I've been looking around and found something called rowTemplate, but the jQuery js file kept throwing error, below is the code snippet:
@(Html.Infragistics().Grid<Matrix>() .AutoGenerateColumns(false) .ID("testGrid") .RenderCheckboxes(true) .Columns(column => { column.For(x => x.ID).HeaderText(" ").Width("80"); column.For(x => x.Description).DataType("string").HeaderText("Description"); column.For(x => x.Status).DataType("string").HeaderText("Status"); column.For(x => x.EffectiveFrom).DataType("date").HeaderText("Effective From"); column.For(x => x.EffectiveTo).DataType("date").HeaderText("Effective To"); column.For(x => x.CreatedBy).DataType("string").HeaderText("Created By"); }).RowTemplate("<tr><td>test</td><tr>").JQueryTemplating(true)
Hi Andy,
Column templates and row templates are basically the same. In fact column template internally is transformed to row template. Column template makes your job easier if you only need to set template for only a subset of the columns.
I've attached a sample which demonstrates how to put a button for alternate rows only.
Hope this helps,
Martin Pavlov
Infragistics, Inc.
Hi Martin,
I would like to add button to every alternate column in the row. I saw this post that you suggest to use column template. As I know that one can achieve the same with rowTemplate. I am just wondering what is the best practice and what are the difference between the two. Thanks.
I found a way around the problem but it's not pretty. I defined my handler like this:
$.onDissociate = function (id_) {
// Handle dissociation here
};
And the onclick looks like this:
onclick=\"$.onDissociate(this.id)\"
It's ugly but it works.
I can run your sample code just fine. However, I have the same code except I am not using the ig.loader to create the grid. When I click on one of the buttons associated with the row, my "handleCopy" method is undefined. I know it is working because I put alert(this.Id) in the onclick attribute and that works just fine. For some reason, it my event handler cannot be found.
Here's my code... as you can see I even tried passing the handler function to the function that creates the grid and that didn't work either. Any Ideas?
I actually just went around the problem by adding an additional property to my view model. I now have UserId and UserId2 and I just bind the button's id attribute to UserId2. Everything works fine. I wish there was a better/cleaner way though.