Hi,
I would like to have the entered value data[0]["cntRelation"] to be always = "Test" even when I enter new values to my grid.
Now when I edit my grid the new entry comes first (in the order of the ["cntRelation"]. What I want is I always want for the new entry to be the last in the order and the value "Test" always the first.
Below is the declaration of my igGrid
$.ig.loader({ scriptPath: './js/', cssPath: './css/', resources: 'igGrid.*', ready: function () { $.getJSON("Home/GetAll", null, function (data) {
var headerTextValues = [, "Name", "Relation to Will maker"]; $('#contactGrid').igGrid({ expandCollapseAnimations: true, animationDuration: 1000, expandTooltip: "Expand to View Details", collapseTooltip: "Hide details", height: "400px", width: "800px", dataSource: data, responseDataKey: "Records", autoGenerateLayouts: false, autoGenerateColumns: false, //to not generate all column and show only the ones i want to display rowEditDialogContainment: "owner", showReadonlyEditors: false, columns: [ { headerText: headerTextValues[0], key: "cntID", hidden: true }, { headerText: headerTextValues[1], key: "cntAKA", width: 250, template: "<a href='Home/ManageContact?cntID=${cntID}&command=edit' class='editDialog'>${cntAKA}</a>" }, { headerText: headerTextValues[2], key: "cntRelation", width: 250, template: "<a href='Home/ManageContact?cntID=${cntID}&command=edit' class='editDialog'>${cntRelation}</a>" }, ],
initialDataBindDepth: -1, primaryKey: 'cntID', width: '800', //updateURL: "Home/Update",
}); }); } });
Thank you
Regards
Sonia
Hello Sonia ,
Thank you for posting in our forum.
In general the changes are not committed to the grid if autoCommit is set to false and the data is not explicitly committed ( via the commit method :$(".selector").igGrid("commit");).
If the changes are not committed the actual data object won’t be updated with the new value.
The data would be automatically committed if something triggers a data bind (like sorting, filtering etc). In that case you can handle the dataDirty event and decide whether to commit the changes to the grid or cancel the event and manually handle the data changes.
For more information on how the dataDirty event can be handled you can refer to:
http://help.infragistics.com/Help/Doc/jQuery/2012.1/CLR4.0/html/igGrid_Updating.html#handling_datadirty_event
Let me know if you have any questions regarding this.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://es.infragistics.com/support
Hi Maya,
Thank you for your email and sorry for my late reply.
What I would like to achieve is to add a condition on my grid's row. Which means I have a static data that has the value "Mother" as a relation type.
Using an editor I can enter persons that have relation with the relation type"Mother". What I want is that the value "Mother" is always the first in the the grid (always the first row no matter how many data(persons) I enter). Also, the value "Mother" doesn't have to exist twice : when someone chooses "Mother" from the editor and click "Done" to save the data, an error message is displayed saying that the value "Mother" already exists in the grid.
Thank you for your help
Hello Sonia,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Developer Support Engineer
I’ve attached an example of how custom sorting could be implemented.
In it for the sorting function a check is added for the text of a specific field and if the field contains that text it will always be sorted to be in the first row.
You can test it by sorting any of the columns. Note that the field with text “Test” will always be sorted to be first in the rows collection.
Let me know if you’re aiming to achieve something similar.
Thank you for your answer.
I am editing my grid data using an external editor (not an IgniteUI one).
I tried the custom sorting to always force a certain value to be the first that appears in my grid columns (on row[0]) but didn't work.
Can you please provide me with an example ?
Based on what I understood from your initial question your aim is to prevent the grid from updating the values in the underlying data source of the grid.
“data[0]["cntRelation"]” I assume is some field from a json data source.
If that’s indeed the case all you need to do is:
Make sure autoCommit is set to false.
Make sure you handle the dataDirty event and cancel it by returning false in the event handler.
If you need to manually update the actual data source(the data object) at this point you can do so before returning false in the event handler.
If the changes from the grid are not commited (autoCommit is false and dataDirty is canceled) then the changes you make on the grid will not be automatically reflected in the actual data source (your ‘data’ object) and you can manually handle the changes.
Let me know if you have any questions or if I’ve misunderstood your initial question.