I used to have the previous version of ignite ui (2012). I had a grid that was functional with no problems.
columns: [ { headerText: headerTextValues[0], key: "cntID", hidden: true }, { headerText: headerTextValues[1], key: "cntAKA", width: 250, template: "<a class='editDialog' href='Home/ManageContact?cntID=${cntID}&command=edit'>${cntAKA}</a>" }, //{ headerText: headerTextValues[2], key: "cntRelation", width: 250, template: "<a href='Home/ManageContact?cntID=${cntID}&command=edit' class='editDialog'>${cntRelation}</a>" }, //{ headerText: headerTextValues[2], key: "cntRelation", width: 250, template: "<a href='javascript;' onclick='return show_more_menu(); class='editDialog'>${cntRelation}</a>" }, { headerText: headerTextValues[2], key: "cntRelation", width: 250, template: "<a href='Home/ManageContact?cntID=${cntID}&command=edit' class='editDialog'>${cntRelation}</a>" },
//{ headerText: headerTextValues[3], key: "cntRelation", hidden: true, width: 250, template: "<a href='FullPage/ManageContactInternal?cntID=${cntID}&command=edit' class='editDialogInternal'>${cntRelation}</a>" }, //{ headerText: headerTextValues[3], key: "hrefUrlTest", width: 250 }, ],
I had a link in the template as shown in the code above.
When I upgraded igniteui to the latest version (2014), the link is no longer functional.
I tried the link as a standalone (outside of the grid template) and it works with no problems but when trying it in the iggrid template it doesn't work.
Sonia
Hi Stamen,
Thank you for your explanation and the sample.
I will try this in my example and let you know.
I will send you a sample as well.
Thank you
Regards
Hello Sonia,
I am sorry, I did a mistake in my original sample. The comparison function should always return an integer. Regardless the first two conditions should make sure that if "Myself" is the value of the property "column" (which is a property of my sample's data source and should be changed for your scenario) it is considered lower than the other value. This will always keep the record containing "Myself" as first. If you run my original sample it should work like this.
Please, find a modified sample with the correct sorting function attached. Change "column" with the property holding the values "Myself", "Mother" and "Father" and you should have the row kept first. Alternatively, if you could provide a small sample of your scenario I could take a look and suggest a complete solution. Please, also have in mind that the approach with a custom sort function will require the sort function to be more robust if you want to have real sorting for the other columns of the grid. This one only sorts by a single property of the records.
Best regards,
Stamen Stoychev
Thank you for your reply.
I applied the same idea to my project but it didn't work.
What I wanted to achieve is always keep "Myself" in the first row not the last one.
I am adding contacts using an external editor.Is this make a difference ?
Please find below the code I implemented in my grid definition.
features: [
{
//Test the custom sorting name: "Sorting", customSortFunction: function (data, fields, dir) {
//the function should return the sorted data return data.sort(function (a, b) {
//this is the compare function used - basically it doesn't care about the sorting expressions that you can find in the fields var. //All it does is check for the "Myself" val and make sure it's always considered higher than the other. Then it sorts by the column property.
if (a.column === "Myself") {
return -1;
}
if (b.column === "Myself") {
return 1; }
if (a.column === b.column) {
return 0; }
return dir === "descending" ? a.column > b.column : b.column > a.column;
});
} ]
Thank you for your help.
I can suggest two ways for achieving this. When you are adding the row that has to be on top you could do it with the insertRow method of igDataSource. You then need to call dataBind to rerender the data.
If you are enabling Sorting anyway and you need to have that row stay first no matter of the sorting expressions applied you will have to define a custom sort function. I've implemented a simple one in the sample I am attaching to the post. You may need to modify it to better match your case.
Please, check the attached sample out and if you need help modifying it to match your scenario let me know!
Thank you.
Yes please. I do have another question.
I have a grid and an editor. I have a drop down list in my editor from where I can choose Mother/Father/Myself.
When I add a new contact using the editor, in the grid a display the relation : Mother/Father/Myself and the name of the contact (grid with two columns). What I would like to achieve is to always display Myself in the first row (line). Which means that no matter how many contacts I add, after adding Myself, I always want to display Myself as the first contact in the grid.
I tried to achieve that using the sorting but I couldn't do it because of the alphabetic order.
Please if you need me to explain more let me know.