Can anyone provide inputs on how can we achieve sorting around firstname/lastname instead of userid.

Hi all,
We have a column in the db which stores userid.

We have a view that queries all other columns in addition to the userid.

While displaying the data on the grid, we are passing the userid to get the user's firstname and lastname.

Everything works fine, but when we sort on the this column, it sorts on the internal userid rather than the firstname/lastname that we had populated.

Can anyone provide inputs on how can we achieve sorting around firstname/lastname instead of userid.

Eg: Userid in db: "A123"

We are passing "A123" to a function to get its firstname/lastname which is "AAA 777".

Now, when we are sorting, it sorts on "A123" instead of "AAA 777".

One idea might be storing firstname/lastname in the db along with userid. If I use this approach, then I will have to modify my CDT to hold these values. I need to implement this change around several grids.

But, wanted to understand if there is any other way.

Any...

OriginalPostID-187277

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    =load(

    /* Assumption:'The employeeId column of myCDT is text'. If it is integer, then one has to create a duplicate cdt with employee id as text type (this cdt should only be used for display purpose). - see more comments below*/

    local!getData:/*"A query entity to fetch the required data*/

    /*The output is cdt in the format of
    [id:123 (int), employeeId: "A123" (text), designation:"Developer"(text)],
    [id:123 (int), employeeId: "A124" (text), designation: "Tester"]
    Now create a new local variable*/

    local!modifiedData:/*Here we will create a dummy cdt*/

    /*type!myCDT{
    id:index(local!getData,"id",null),
    employeeId:apply(rule!getFullname,index(local!getData,"employeeId",null)),
    designation:index(local!getData,"designation", null)
    }*/

    with(
    local!datasubset:todatasubset(local!modifiedData,local!paginInfo),
    /*create grid now*/
    )
    )
Reply
  • 0
    Certified Senior Developer
    =load(

    /* Assumption:'The employeeId column of myCDT is text'. If it is integer, then one has to create a duplicate cdt with employee id as text type (this cdt should only be used for display purpose). - see more comments below*/

    local!getData:/*"A query entity to fetch the required data*/

    /*The output is cdt in the format of
    [id:123 (int), employeeId: "A123" (text), designation:"Developer"(text)],
    [id:123 (int), employeeId: "A124" (text), designation: "Tester"]
    Now create a new local variable*/

    local!modifiedData:/*Here we will create a dummy cdt*/

    /*type!myCDT{
    id:index(local!getData,"id",null),
    employeeId:apply(rule!getFullname,index(local!getData,"employeeId",null)),
    designation:index(local!getData,"designation", null)
    }*/

    with(
    local!datasubset:todatasubset(local!modifiedData,local!paginInfo),
    /*create grid now*/
    )
    )
Children
No Data