Example of dependent() for filtering type: datatable

Example of dependent() for filtering type: datatable

jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1

Does anyone have a link to an example of using editor.dependent(), but instead of updating a select (via options), updating a datatable type instead?

Answers

  • jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1

    To be slightly more specific on the problem/request, I'm unsure how to reference a "type: datatable" inside an editor definition, to update/refresh the data within it. I can use editor.dependent() to trigger all the necessary workflow to create a filtered dataset, I'm getting it returned, I have it, but unsure how to send that to the editor datatable element to refresh its contents.

  • jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1
    edited March 25

    Figured it out ...

      editor.dependent('a_id', function (val, data, callback) {
        $.ajax({
            type: "POST",
            url: '/api/dt/filter',
            async: true,
            data: { values: { 'id': val } },
            dataType: "json",
            success: function (data) {
                console.log('data',data);
                editor.field('a_id').update(data.results);
                return;
            }
        })
      });
    

    Not as classy as updating the "options" table, but it works! :D

  • jacob.steinbergerjacob.steinberger Posts: 86Questions: 18Answers: 1

    That leaves figuring out how to re-select the values, if you're editing something that has already been built ...

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Editor should handle the reselection of values automatically. Can you give me a link to a page showing the issue please?

    Allan

Sign In or Register to comment.