How to combine two tables? or interact with another subset of data - Page 2

How to combine two tables? or interact with another subset of data

2»

Answers

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916
    edited December 2022

    Your test case is working:

    Your screenshot shows fixedColumns: {left:1}, not left: 5 as you code snippet depicts and what is configured in the test case.

    Kevin

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    Hi @kthorngren

    I created a function to render the name in a different colour if the blackList key is either 0 or 1, however, only 1 colour is being returned.

    http://live.datatables.net/nubafowe/2/edit

    function blacklist(row) {
    
        if (row.blackList = 1) {
            return '<span class="recipient-blacklisted">' + row.name + '</span>'
        } else {
            return '<span class="recipient-notblacklisted">' + row.name + '</span>'
        }
    }
    
    
            {data: 'name', title: 'Recipient',render: function (data, type, row, meta) {return blacklist(row)}},
    
  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916
    Answer ✓

    if (row.blackList = 1)

    using one = is not a comparison but sets a value. You need to use either == or === for comparisons. See this tutorial.

    Kevin

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    ah indeed, is working now! thanks for the pointer.

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0
    edited January 2023

    Hi @kthorngren @allan

    I am trying to pre-configure the order of the columns so that I can organize services by grouping them in sequential order, so I started by hardcoding the order but doesnt seem to work.

    http://live.datatables.net/muzeriza/1/edit

    I've tried

    order: [ 4, 3, 2, 1, 0, 5,6,7,8 ],
    

    and also on subscription button click

                          new $.fn.dataTable.ColReorder( table, {
                            order: [ 4, 3, 2, 1, 0, 5,6,7,8 ]
                            // options
                        } );
    
                    /****************TESTING ****************/
    

    as well as on completion but I can't make it work

              /****** REORDERING TESTING ****/
                        initComplete: function () {
                var api = this.api();
       new $.fn.dataTable.ColReorder( api, {
                            order: [ 4, 3, 2, 1, 0, 5,6,7,8 ]
                            // options
                        } );
                api.columns().invalidate().draw();
              }
              /***************************************/
    

    ultimately I want to automate this so, I am passing the order through services using a key "order":4 so that I can then somehow use the value from this key to pass to the order option.

            let services = [
            {data:null,defaultContent: '',"title":"UK &gt; Advisers &gt; Services", "id":"321814", "order":4},
            {data:null,defaultContent: '',"title":"Newsletter", "id":"3721", "order":3},
            {data:null,defaultContent: '',"title":"Sustainability","id":"15656200", "order":2},
            {data:null,defaultContent: '',"title":"UK &gt; Private Clients &gt; Services", "id":"3218140", "order":5},
            {data:null,defaultContent: '',"title":"UK Branded Dialogue", "id":"3218141", "order":1},
            {data:null,defaultContent: '',"title":"UK &gt; Private Clients &gt; Content &gt; Newsletter", "id":"3218142", "order":7},
            {data:null,defaultContent: '',"title":"UK &gt; DFM &gt; Content &gt; Newsletter", "id":"3218145", "order":8},
            {data:null,defaultContent: '',"title":"UK &gt; DFM &gt; Valuation Email","id":"16965220", "order":6},
            {data:null,defaultContent: '',"title":"US Branded Dialogue", "id":"6161413", "order":0}
            ];
    
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin

    You'd need to pluck the order parameter from that array of objects and make an array.

    One thing I'm not clear on though - do you need to use ColReorder? Could you not put the columns in the correct order without using ColReorder? It would be so much faster. E.g. just sort your services array by that parameter before passing it to DataTables.

    Also, in your example your order array for ColReorder doesn't define all columns - it must be the same length as the number of columns in the table. I'd still recommend just sorting the array first though.

    Allan

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    Ah, thats a good idea al, thanks Im working on it.

    By the way, quick question on performance, the webapp im building will be loading 100k records, and right now im testing on just 400 records and notice a huge performance hit on filtering the records.

    Any idea what may be causing this, or how to improve it, here is a recording I made https://somup.com/c0VFFzxobh

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin

    It really shouldn't be noticeably slow with just 400 rows. 100k would crush it!

    Are you using server-side processing? You'll need to (with paging enabled) if you are going to have 100k records. Also the viewTotal / viewCount / cascade options in SearchPanes really slow things down, particularly when server-side processing is enabled.

    Allan

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0
    edited February 2023

    Hi @allan @kthorngren

    So I replicated some records (1k in total) and services in the dev mock example, and I can definately see performance issues whilst interacting with the filters, how does one troubleshoot at which point is the bottleneck ocuring? perhaps applying functions to the columns or something else?

    https://live.datatables.net/muzeriza/2/edit

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0
    edited February 2023

    Furhermore, I tried the search filter with those 1k records and it freezes when I type a single character, I ended up removing on another dev test case the functions applied to the columns and rows to render the toggle buttons and other bits, and did not notice any improvement, so the issue seems to lie when filtering, but I don't know what can be done.

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    @colin for visability

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    On your example 50k performance page, you can also see how the filter lags for too many seconds before it filters the data out

    https://datatables.net/extensions/searchpanes/examples/performance/cascadeViewTotal50k.html

  • latinunitlatinunit Posts: 73Questions: 12Answers: 0

    I've loaded only 15 records and it shows the slugish performance of the filters,

    Please see here recording https://somup.com/c0nbbZxWBg

Sign In or Register to comment.