row().child.isShown() in columnDefs

row().child.isShown() in columnDefs

MausinoMausino Posts: 61Questions: 19Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hi, i found https://datatables.net/reference/api/row().child.isShown()
also i see documentation here https://datatables.net/reference/api/row().child
also i looked on api... the table is NOT SERVERSIDE loaded

in columDefs i have

            { targets: 9, data: null, title: 'Firma', className: 'hide', orderable: false, defaultContent: '',
                render: function (data, type, row, meta, title) {
                    if (type === 'display') {

                        return format(row.ID);

                    }
                }
            },

i want load by ajax by eg format() function data to table, but i have not serverside loaded the main table... i dont want load for all records eg 100 but only 10 which are paginated on first list... or only showed in table

It is possible also somehow use function for row or child like isShown() or something simmilary, that will load data only for tables which are showed and ohter which are on other page list will not ?

Miky

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,890Questions: 1Answers: 10,143 Site admin
    Answer ✓

    There is no way to use isShown() in a rendering function - sorry. Also, loading Ajax data in a rendering function is really not a good move - the rendering function can be called many times per cell and will be called for every cell on every row. The upshot if that is you'd send a whole bunch of Ajax requests to the server just to draw a single page.

    I'm not clear on what it is you are trying to achieve here? What is the end goal?

    Allan

  • MausinoMausino Posts: 61Questions: 19Answers: 0

    Hi, thank for your answer.

    The main goal is that i got data about locations.

    as you can see to in first column are 4 numbers with icons. In my case enqury, free flats, reservations, support questions.

    There is only demo data numbers. But if you click on one of this number you open modal window where you have informations about your current status of one of this 4 categories.

    The main problem is, that if you have around more as 200 rows, because it possible filter the markers by datatable, i must calculate all data in background and this is problem for me....

    My goal is if i have pageLengh 10, after load all data.. only for this 10 record will call next ajax where will this calculations done.

    I tried as second ajax now and you have right that was call many times per cell... what make me problems.

    Thank you for your anser.
    Miky

  • allanallan Posts: 61,890Questions: 1Answers: 10,143 Site admin

    i must calculate all data in background

    What calculation? I'm not clear on that part.

    Allan

  • MausinoMausino Posts: 61Questions: 19Answers: 0
    edited April 2023

    Hi, user see only 10 records, max 50 (by set up of datatables)...

    And it make for me big difference calculate and return results for 10 or max 50 results at one request or 200+ results in request

    Problem is response of page.. because it takes time to return calculated data based on location. For whole table is one time of 20 000 objects with gps.... with each section is 4 times for each row of 20 000 objects.. More rows more to calculate.. more time to load response...

    I can solve this problem by serverside loading of data... but this is not compatibilie with google maps 2 ways filter of data like we have now... (if you filter data by search you will see only markers which are in table by drawCallback window.myData = this.api().rows({search: 'applied'}).data().toArray(); and filter data in datatable from map by $.fn.dataTable.ext.search.push()

    Miky

  • allanallan Posts: 61,890Questions: 1Answers: 10,143 Site admin

    Apologies - I'm still not quite getting it. I suspect it is just because I'm not familiar with your app and how it works, so I don't have the full domain knowledge of it you do.

    If I understand correctly you need to make calculations for each row (based only on the data in that row?), and you want to do that with an Ajax call? And then show the result in a child row?

    Sorry - its late on a Friday, so apologies, if I'm just being dense. I'm just not seeing the bigger picture. If you could link to your page, that would probably help.

    Allan

  • MausinoMausino Posts: 61Questions: 19Answers: 0

    Now, i am experimenting with technique called "debouncing" in JavaScript.

    This may solve my problem if cell is loaded many times on beginning.
    https://medium.com/walkme-engineering/debounce-and-throttle-in-real-life-scenarios-1cc7e2e38c68

    if i push the function as render in columnsDefs :)

    Miky

  • MausinoMausino Posts: 61Questions: 19Answers: 0

    :) to bigger picture

    We have app where we searching data base on gps position.. like find me this type of data (enquiry) in London by 15 km max in this time frame.

    You get list of record which are in this area. But every record can has own list of available categories which are also calculate by gps and i need there the distance of which is this record far from. Now i have 4 and each must find them mainly by gps.

    Example....
    You require in some location accommodation, with time frame and price... our role is find the reservations, free flats, etc for this record in onw distance defined by client..

    This mean each record in list has gps and from gps are calculated related subrecords. Do this in one big response is time consuming... this is why i need show the list of records (enquiries) first and after row by row i will additionaly calculate the relate subdata for each row.

    Sorry for English
    Miky

Sign In or Register to comment.