Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Ignite UI - Angular 2, column sorting does not work without a primary key
posted

Hi, I am using Angular 2 igGrid. I am experiencing an issue where sorting on a column doesn't work if a primary key is not provided in the gridOptions.

From the documentation, a primary key is not required in the example:

http://www.igniteui.com/help/api/2016.1/ui.iggridsorting

Clicking on any column header would reduce the number of records to a single row.

The data that I have can contain duplicates in each of the columns. If I send in the key for a column with duplicates, the same sorting issue occurs.

If a primary key is required for the sorting to work properly, should I create a surrogate key as a primary key and hide that column?

Thanks!

-Jessica

this.gridOptions = {
dataSource: this.gridData,
width: "100%",
height: "400px",
autoGenerateColumns: false,
primaryKey: "a",
columns: [
{ key: "a", headerText: "A", width: "30%", dataType: "string" },
{ key: "b", headerText: "B", width: "40%", dataType: "string" },
{ key: "c", headerText: "C", width: "30%", dataType: "string" },
],
features: [
{
name: "Paging",
pageSizeDropDownLocation: "inpager"
},
{
name: "Sorting"
}
]
}

Parents
No Data
Reply
  • 3995
    Offline posted

    Hey Jessica,

    The primaryKey is not required when using the Sorting feature and I'm not sure why you are facing this issue.

    Could this be something with the data and using incorrect dataTypes?

    Is this your complete grid configuration?

    Can you provide a complete sample demonstrating this or do you want me to send you working one without a defined primaryKey?

Children