colReorder.order() issue with columnDefs.data()

colReorder.order() issue with columnDefs.data()

MichaelBradeMichaelBrade Posts: 5Questions: 3Answers: 0

Hi, if I initialize my table with colReorder, using a columnDefs for all columns of a specific object:

    columnDefs: [ {
          targets: "attr",
          data: function(data, type, value, meta){
            var api, col;
            if (type === 'set') {
              console.warn("setting values not supported!");
              return;
            }
            api = meta.settings.oInstance.api(true);
            col = meta.col;
            try {
              col = api.colReorder.order()[meta.col];    // because here it crashes during init
            } catch (e$) {
              console.log("not yet");
            }
            
            return this$.getAttribute(data, col);
          }
        ...

then I get a crash because colReorder is initialized after data() is called, i.e., the preInit event is fired after data(). Is that intentional? My workaround is the try {} catch () {} above but this is not a nice solution.

Also, talking about this, why do I need to call colReorder.order() at all? I would change the API so that meta.col is the original column index, not the currently rendered column. Only then colReorder would be transparent to use.

Answers

  • MichaelBradeMichaelBrade Posts: 5Questions: 3Answers: 0

    Hi Allan, any comment on this? Are you busy with other things and this has a low priority, or do you need more information, or...?

    As I wrote, IMHO the ideal solution would be to change the meta.col argument to be independet of ColReorder in columnDefs.data() and columnDefs.render().

This discussion has been closed.