Hi guys,
My company has asked me to evaluate your IgniteUI product, and so far, I've had nothing but problems.
For example, I want to use the IgniteUI ig-grid control with Angular. Pure Angular... no messing around with jQuery calls, etc.
Your scarce examples seem to all use hardcoded Northwind JSON data, and I can't find a simple ig-grid / Angular example to learn from.
For example, in this thread, a user asked how to call a function if a user clicks on a row.
http://es.infragistics.com/community/forums/t/101555.aspx
The answer was to use "event-active-row-changed", but their follow-up question, "Where is this actually documented ?" was ignored.
I have the same kind of issue.
I want to kick off a function in my Angular controller when the user has edited something (in-line) in their ig-grid (so I can kick off a WCF web service to save the changes back to SQL Server), but I can't find any example code anywhere.
I'm sure there's a simple answer to this, but your documentation and examples are hopeless, or resort to using jQuery.
Can someone help, please ?
Mike
I should add, I'm happy for the "on save" event to trigger a REST web service, but, again, I would like an example showing how this can be achieved using the ig-grid Angular control.
http://www.igniteui.com/help/iggrid-rest-updating
Here's how far I've got, without an examples to help me:
<ig-grid id="iggrid1" data-source="ListOfRecords" width="100%" height="240px" primary-key="UserID" auto-commit="true" auto-generate-columns="false"> <columns> . . . </columns> <features> <feature name="Updating" enable-add-row="true"> <column-settings> <column-setting column-key="UserID" read-only="true"> </column-setting> </column-settings> </feature> <rest-settings> <create url="/api/users/"> </create> </rest-settings> <feature name="Selection" > </feature> <feature name="Updating"> </feature> </features></ig-grid>
The grid displays some data, I can edit it and add rows, and when I click on Done, the Angular variable does get updated, but the REST URL doesn't get called, and I can't find any sample code to get this working.
Hello Michael,
Ignite UI is a product built on top of jQuery and jQuery UI frameworks. Its support for Angular is in the form of custom Angular directives which initialize controls declaratively as well as support for two-way data binding for igGrid, igComb, igEditors and igTree. In that sense we don't provide a complete Angular experience, because that would require a completely new product specifically built on top of the Angular framework. This means that you cannot run away from using the jQuery calls at runtime.
The project is developed publicly on GitHub: https://github.com/IgniteUI/igniteui-angular and all the concepts used for the directives are explained there. One should still use the Ignite UI API docs for development purposes, because we don't provide an API docs for the directives.
The answer of the question: "Where is this actually documented ?" is "In the section "Handling Events" on GitHub with the events listed in the Selection feature API docs".
Returning back to your main question. There is an API igGrid.saveChanges which will send all the pending transactions to the remote URL configured in the grid. You can call this API on the igGridUpdating.editRowEnded event. I'm attaching a sample for your reference.
Best regards,Martin PavlovInfragistics, Inc.
Hello Michael, Alex,
To start with binding the igCombo data source you need to evaluate the data source value (Note: This is not done automatically for the childs of the ig-grid tag). This is done with the following syntax:
<editor-options data-source="{{ListOfPrograms}}" text-key="ProgramName" value-key="ProgramID"></editor-options>
This code will bind the editor-options data source to the local $scope.ListOfPrograms variable.
Now that you bound the combo editor to some data you'll notice that after the edit finishes the value displayed in the grid is from the igCombo's valueKey setting. This is because the igGrid doesn't do the lookup automatically and you should do it yourself using a igGrid.columns.formatter function callback. I'm attaching a working sample to demonstrate combo editor scenario with different valueKey/textKey pair.
Alex Grape said:Actually, this "ListOfPrograms" array will be a JSON array populated by a web service (so its data won't be available when the page first loads).
Populating igCombo editor provider from a web service will not work as expected for architectural reasons. You should bind the igCombo to a local $scope data.
Alex Grape said:How do I tell the ig-grid that this drop down list's "data-source" has changed.... or does this data-source only "kick in" when the user edits a row, and the ig-grid evaluates what this ListOfPrograms contains at that point ?
The data source is only evaluated once when the combo editor provider is created. Although it's possible with the following API call $(".selector").igCombo("option", "dataSource", newDataSource);, changing it dynamically will lead to errors like lookup data in the combo cannot be found.
Hope this helps, Martin Pavlov Infragistics, Inc.
Hi Martin,
Many thanks for the reply.
Your sample code answered a lot of questions for me, except for one.
I still find that, with hardcoded data (like you used), there's no problem.
But if I set up a web service to return that same data, store it in the same $scope variable, I still can't get the simple array of values into the drop down list.
And if I try your suggestion to bind this data:
$("#MikesGrid").igCombo("option", "dataSource", $scope.ListOfCities);
...then I get this JavaScript error...
Uncaught Error: cannot call methods on igCombo prior to initialization; attempted to call method 'option'b.extend.error @ jquery-1.9.1.min.js:3(anonymous function)
What would be useful is if you could change your sample so rather than hardcoding the values...
$scope.ListOfPrograms = [ { "ProgramID": 1, "ProgramName": "First Program" }, { "ProgramID": 0, "ProgramName": "Second Program" }];
...you simulated loaded this data from a web service...
$scope.ListOfPrograms = null;
setTimeout(function () {
$scope.ListOfPrograms = [{ "ProgramID": 1, "ProgramName": "First Program" }, { "ProgramID": 0, "ProgramName": "Second Program" }];
// Need to use $apply, as we're setting an Angular value in a timer thread
$scope.$apply();
// Attempt to tell our ig-grid that the data has changed
$("#grid1").igCombo("option", "dataSource", $scope.ListOfPrograms);
}, 1000);
According to your email, this should work.
In reality, your sample also throws this "cannot call methods on igCombo prior to initialization" error.
Best regards,
Michael Gledhill said:But if I set up a web service to return that same data, store it in the same $scope variable, I still can't get the simple array of values into the drop down list.
The reason for this approach not working is because the evaluation that we're doing with scope.$eval probably copies the data and loses the reference to the original data source.
Michael Gledhill said:Uncaught Error: cannot call methods on igCombo prior to initialization; attempted to call method 'option'b.extend.error @ jquery-1.9.1.min.js:3(anonymous function)
This error is expected and the reason is that the editors are not created at igGrid initialization time, but the first time the user enters edit mode. To resolve it you need to force editor creation when you want to set its data source. This is done with the igGridUpdating.editoForCell API which second param should be set to true. I'm attaching a modified sample demonstrating this approach.
Hope this helps,Martin PavlovInfragistics, Inc.
Looking at your code I see that there is an issue with the following code:
$("#grid1").igGrid("cellById", 1, "ShipCity");
It doesn't return any cell and the reason is that the second argument should be a valid primary key value and your data doesn't have row with id = 1. To resolve this you can get the first row pk value like this:
parseInt($($("#grid1").igGrid("rows")[0]).attr("data-id"))
The resulting code will be:
$combo = $("#grid1").igGridUpdating("editorForCell", $("#grid1").igGrid("cellById", parseInt($($("#grid1").igGrid("rows")[0]).attr("data-id")), "ShipCity"), true);