How to use "e" parameter of endEdit method? Documentation says:
.igGridUpdating( "endEdit", [update:bool], [e:object] );
Hello Luis,
This particular event is provided to end the row editing manually (when the row is putted in edit mode). In order to handle the event which is raised after that method you can handle editCellEnded/Ending or editRowEnded/Endind depends if you are using cell or row editing type.
Thanks Kolev, I understand what the method (not event) does but not how to use its parameter "e", could you bring an example of how to use it? what are the benefits of that parameter? I think there is a lack of information in this regard in the documentation, maybe I am wrong. Thanks again ;)
You shouldn't pass anything, when you start to edit some cell for example and move the focus from the cell somewhere out of the igGrid we internally call "endEdit" method and we pass event arguments. If you call it manually from the client, Updating and Updated client event wont be fired unless you pass second parameter "true", then the events will be fired:
$("#grid").igGridUpdating("endEdit", true);
"#grid"
).igGridUpdating(
"endEdit", true
);
We have internal check if the browser event exists, and if you pass true the condition will be fulfilled and Updating and Updated events will be fired.
If you want to be more familiar with the jQuery event handlers please have a look at the article below:
How can I pass arguments to event handlers in jQuery?
Sorry Kolev and please be patient with me, I am not good at jQuery or JavaScript (yet), I think you don't understand my question or I am not explaining properly. I already know what the "update" parameter does, I am stuck with parameter "e", I don't know what kind of object should be passed to this parameter to do who knows what. If I pass "true" to parameter "update" it will update the grid with new values as it is declared in the documentation, but if I pass an object to paramter "e" what will happen? The documentation says "events are rised", Which events? If I have something like:
var myObject = new Object();
$("#grid").igGridUpdating("endEdit", true, myObject);
"endEdit", true, myObject
What will igGridUpdating does? It would be easier for me if you proived a simple example. Thanks.
Hello,
Yes, your assumption is correct, you can pass myObject to the event handler argument and access it later in editCellEnded event (which will be fired because you are passing true like a second parameter).
Code snippet:
<script> var data = [ { "ID": 1, "Name": "John Smith", "Age": 45 }, { "ID": 2, "Name": "Mary Johnson", "Age": 32 }, { "ID": 3, "Name": "Bob Ferguson", "Age": 32 }, ];
$(function () { $("#grid").igGrid({ primaryKey: "ID", dataSource: data, //JSON Array defined above features: [ { name: "Updating", enableAddRow: true, editMode: "cell", enableDeleteRow: false, enableAddRow: false, editCellEnded: function(evt, ui){ alert("editCellEnded");
//evt.originalEvent will return you the object } } ] }); }); function StartEdit() { $("#grid").igGridUpdating("startEdit", 1, 1); } function EndEdit() { var car = { type:"VW Golf", model: 4, color: "silver"}; $("#grid").igGridUpdating("endEdit", true, car); } </script>
this example the event editCellEnded does not fire when working with new row
I am glad to hear that you find my reply helpful.
Thank you for using our products.
Thank you so much Kolev!!! now is crystal clear to me :) This is the kind of documentation I need it.
Let me know if I may be of further assistance.