Search code examples
reactjsgridviewcxjs

CXJS - How to get the record.id from link onclick within the Gridcell


I am still learning things on both react and cxjs. I am trying to develop a lookup widget which pops a window with a grid and the user can search and select an entry from that.

I want to use a Link within cxjs grid cell and when clicking the link I need to call a controller method with id of that particular row (record.id). Below is what I have tried with no success.

  .....
  style="max-width: 500px; width: 500px; max-height:500px;"
              border={false}
              columns={[
                  {
                    field: 'name', sortable: true,
                    items: <cx>
                        <Link onClick={(e, ins) => {

                          ins.store.set("$lookup.selText", e.? /* can I use e to get id and set it to store */);
                          ins.controller.selectRecord("{$record.id}");  // this doesn't work either
                          ins.parentOptions.dismiss();
                        }} text-tpl="{$record.name}"/>
                    </cx>,
                    header: {
                        style: 'width: 150px',
                        items: 'Name'
                    },
                },

Could someone please shed some lights?

Thanks,

Priyanga


Solution

  • You can get the value from the store using the get function.

    store.get("$record.id")