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
385
Multiple primary keys?
posted

Hi,

is it possible to have multiple primary keys in the grid? I'm getting a list of objects from a remote server, these objects are identified by two numbers. The user should be able to select one or more rows and when a button is pressed, a list of selected objects (or only their identifying properties) should be sent back to the server. 

The problem i'm having is that by calling "selectedRows" i'm not getting the whole data of the row, but only the primary key. It would also be useful to get the whole record-data by calling "selectedRows" instead of just the index.

 

Any ideas?

edit: Ok, i added an invisble column to the dataset containing the combined key. But no i found a bug i think. I'm using selection with row selectors. When clicking the checkbox top left to select all, i get only IDs for the visible rows after calling "selectedRows" (i'm using row virtualization, it may be related). Every row is checked, but for the invisible rows the value of "id" is "undefined". 

  • 10685
    Offline posted

    I am just checking the progress of this. Did you find the time to look into my suggestions?

  • 10685
    Offline posted

    Please let me know how these suggestions work for you!

  • 10685
    Offline posted

    Hello, 

    In general with Fixed Virtualization, only the visible rows are rendered in the grid and these rendered rows are used later as a container for the generated data. As users start to scroll the grid, and data in the pool of rows is updated and the rows DOM elements are reused. With Fixed Virtualization, all igGrid features except the Grouping features (i.e. Paging, Sorting, Filtering, and Selecting), work as expected. So you have access only to the visible-rendered rows. 
    http://help.infragistics.com/Help/Doc/jQuery/2013.2/CLR4.0/html/igGrid_Virtualization_Overview.html

    There are a few options. You could use the igGrid’s findRecordByKey Method, in order to access a specific record. More details regarding this method could be found at:
    http://help.infragistics.com/jQuery/2014.1/ui.iggrid#methods
    I suggest trying to implement this method for your requirements as is flexible and should work for most scenarios and features enabled for the grid.

    If you only care about the columns you can SEE... i.e., you've hidden some columns but you don't need to access them, then you can just access the ui object when for example the editRowEnd or editRowEnding events fire.

    Otherwise, you need to use the underlying dataSource's dataView. Here's how it all should look, including grid:

     grid = $("#grid").igGrid({
       height: 400,
       width: null,     //if null, the grid should stretch to fit
       virtualization: false,
       autoGenerateColumns: false,
       columns: [

         ......

       ],
       autoupdate: false,

       features: [

        { name: "Updating",

            enableAddRow: true,

            enableDeleteRow: true,

            editMode: 'row',

            editMode: 'cell',

            enableDataDirtyException: false,

            rowAdded: function(evt, ui) {
              alert("this is a visible column (title): " + ui.values.title);
            },
            editRowEnded: function(evt, ui) {
              var row = ui.owner.grid.dataSource.dataView()[ui.owner._rowIndex];
              alert("this is my id column, which is hidden: " + row.id);          

            },
            rowDeleted: function(e, ui) {
              ... do something
            }
        },

    Using the dataView and the index will work also for sorted  igGrids, because it is independent from the original igGrid DataSource.

    Please let me know how these suggestions work for you!