an issue with a record grid view will not sort a field

A Score Level 1
I have an issue with a column in a record list grid view. I have an element of the array that needs to correspond to another table using a lookup table and foreign keys, this element is a list of strings. so I created a expression rule and query rules to fetch the correct data. then in the grid I entered the rf!IdValue as the field,

the result was the the data was correct on the initial load but would not sort with the other data , remaining in the same rows instead of matching the other sorted rows.

I also tried adding the IdValue to the array that was returned from the expression rule. the results to this was when the sort changed the Id would move with them but the other values would not move. I have verified the expression rule is returning the correct values.

OriginalPostID-266891

  Discussion posts and replies are publicly visible

  • As far as I can understand you need cdt that contains your data and not different arrays. So you have to first populate all your data into cdt using type!CDT() and then use the cdt fields( which will be tied as dataprovider to grid) as grid field to sort. But this has extra processing. In your case if you create a view and map it to cdt and use it for record grid view then your sorting problem will be resolved.
  • hi christopher: in my last project i didn't have DB user rights to create views. so one day when having to make a paging grid that required multiple reference table joins i tried to get around having to create a view and made a bunch of query rules. This didn't work as i wanted to. Create a view in your database. Map it with your XSD file to your CDT and publish that cdt in your datastore. then just pass the list of that cdt to your grid's datasubset. in your gridTextValue just have your data parameter pointing to the correct property in your CDT array and the field parameter should point to the same name. Then you will find sorting will work on this column. When you try to juggle different arrays to simulate table joins in the database it is not as effective. all of your grids that require lookup tables should be populated from views. its better practice and its easier in the long run.
  • In similar cases where we need to show data from a table having references to some small lookups (less than 100 records), we use display cdts. If we are supposed to display data from a table having references to other transactional tables then using views/nested CDTS is a better approach.

    way to build grids using display cdts is

    1. Create a CDT with enough number of text,number,date fields as per your requirement
    like
    {
    text1,....textn,
    integer1,...integerm,
    decimal1...decimaln,
    date1...datex,
    datetime1..datetimey
    }
    2. use below logic to show your record in grid using display cdt.
    The advantage of using this approach is it will reduce number of calls by calling more data at once. however if you have veryhuge lookups go for view.
    load(
    local!records:rule!queryRuleOrEntityTogetTransactionalData,
    local!lookupDataForFieldn:rule!queryRuleOrEntityTogetLookupsForExisitingRecordField1(fn!index(local!records,"field1",null)),
    ........
    local!data:fn!apply(rule!costructDisplayCDT(_,local!lookupDataForFieldn,....),local!records)
    local!datasubset:(local!data,pagingInfo()),
    grid(local!datasubset)

    )