Change inline value before display

Change inline value before display

eurosolleurosoll Posts: 13Questions: 7Answers: 0

Hi

Firstly, thanks for answering all my recent questions!

My scenario is as follows.

My database stores money in pennies (so £100 = 10000).

When the data comes through to datatables I have set a render function to convert them to pounds and pennies - which is working fine.

The issue is that when the inline editor is opened it shows the original data.

I tried putting an event listener on preOpen but it is not helping:

    transactionEditor.on('preOpen', function (e, mode, action) {
      
      if (mode == "inline") {
        var modifier = transactionEditor.modifier();
  
        if (modifier) {
          currentRow = stTable.row(modifier.row).data(); 
          currentRow.AllocCurrencyAllocatedAmount /= 100;
        }
     }
    });

Do you have suggestions?

I really appreciate your help.

Thanks

Dov

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @eurosoll ,

    You can do something like this - I'm rendering the position column differently and then keeping that in the inline edit. I think the code could probably be optimised, but it's a starting point.

    The only problem you'll have doing it this way, is that you'll need to change the data back to the expected format before the submit. You could do that tweaking in the preSubmit.

    Cheers,

    Colin

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    I would suggest that you use the raw data that you want to be able to edit in the JSON data source, and use a renderer to format the data as needed for the DataTable display. Editor will always work on the raw data.

    Allan

This discussion has been closed.