How to save a row order in grid

Hi All,

I'm a beginner of Appian, and I would like to know how to save a row order in a grid.

In a grid in an interface, I put a arrow for up and down to move rows.

I need to save the order, so the changed order should be saved and updated to DB.

I should create a column in DB to save a row order, but it does not work.

What I want to do is ... when I change the row order by clicking arrow icon and the order is changed, I would like to save the ordering information for next time. When a user open the window next time, a user requires to see the row which was changed by user clicking an arrow.

I need your help.....

Best regards,

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

      You can use a Id with the above map data . Id will uniquely identify each record same as like Db primary key . You can use below code i just tried for down functionality you can use same for Up as well .

    a!localVariables(
    local!items: {
    { id: 1, item: "Item 1", qty: 1, unitPrice: 10 },
    { id: 2, item: "Item 2", qty: 2, unitPrice: 20 }
    },
    a!gridLayout(
    label: "Products",
    instructions: "Update the item name, quantity, or unit price.",
    headerCells: {
    a!gridLayoutHeaderCell(label: "Item"),
    a!gridLayoutHeaderCell(label: "Qty"),
    a!gridLayoutHeaderCell(label: "Unit Price"),
    a!gridLayoutHeaderCell(label: "Total", align: "RIGHT"),
    a!gridLayoutHeaderCell(label: " "),
    
    },
    rows: a!forEach(
    items: local!items,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    value: fv!item.item,
    saveInto: fv!item.item
    ),
    a!integerField(value: fv!item.qty, saveInto: fv!item.qty),
    a!floatingPointField(
    value: fv!item.unitPrice,
    saveInto: fv!item.unitPrice
    ),
    a!textField(
    value: a!currency(
    isoCode: "USD",
    value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
    ),
    readOnly: true,
    align: "RIGHT"
    ),
    a!richTextDisplayField(
    value: {
    a!richTextIcon(
    icon: "arrow-circle-down",
    showWhen: not(fv!isLast),
    link: a!dynamicLink(
    saveInto: {
    a!save(
    local!items,
    a!update(
    local!items,
    {fv!index,fv!index+1},
    {index(local!items,(fv!index+1),null()),fv!item}
    )
    )
    }
    )
    ),
    a!richTextIcon(icon: "arrow-circle-up")
    }
    )
    }
    )
    ),
    rowHeader: 1
    )
    )

  • 0
    Certified Lead Developer
    in reply to PavanSrihari

    Makes code more readable.

Reply Children