Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Searching ListGrid by primary key

    Is it possible to set a primaryKey field in a ListGrid, and then use a primary key value to search for a record?

    My use case is this: after the ListGrid loads I need to retrieve selected sets of child data and associate each row of child data with each ListGrid row so that I can show the child data when the user hovers the mouse over a record. To accomplish that, I'm sending a request to the server that retrieves child data associated with primary key values. However, when I get the data back I need to properly associate it with the parent records, but I'm not sure how to use that primary key to find the right parent record. Any advice?

    #2
    If you are accessing child data through fetchData, you can supply a requestProperties argument that identifies the parent record, and access that information through your callback in the dsRequest variable.

    Comment


      #3
      I've corrected this problem by creating a map between key values and row numbers, and then passing that map to clientContext. When the child rows come through, they get associated with the record at clientContext.idMapping[record[idField]]. I.e., I made an index table that allows me to search by index.

      I'd still like to know if there's a simpler way to do this, though. If not, it would be neat to see that in the next SmartClient release.

      Comment


        #4
        Originally posted by Isomorphic
        If you are accessing child data through fetchData, you can supply a requestProperties argument that identifies the parent record, and access that information through your callback in the dsRequest variable.
        The problem is that I want to request all the child data for all records all at once, to avoid the delay to request data for each individual record on demand -- so there are actually about 50 parent records, not one. The data source returns foreign keys for each child record so that I know which child row goes to which parent.

        Comment


          #5
          Which databinding strategy are you using? If you really want to fetch all the data up front, you can just send it back as subobjects of the master records, stored under some property.

          Comment

          Working...
          X