Code Monkey home page Code Monkey logo

Comments (5)

virtualgadjo avatar virtualgadjo commented on July 24, 2024 1

Hi,
and thanks a lot for your answer, great idea i hadn't thought about...

the problem is that once in the page i have already set a few data attributes to the tds and it works fine but i can't access the db column names i'll need to launch some custom editing modals linked to the line/row id (this works with js but not for the db column name which is different from the head th title)

and i agree i think that with your idea i'll be abble to edit only some column depending on their name (preg_)matchnig some string but your tool is so fast thet i've made a few trires editing all the column with the seame result

foreach($dts as $sl) {
    $datatables->edit($sl, function($data) {
        return '<span data-col="'foo">foo</span>';
    });
}

and there was nearly no difference from the same table without editing (more than 22000 tds when displaying the full table - what should not happen...!) but sure, with specific data it may be a little slower

i use native queries without CI query builder and your adapter works faster than will coyote :)

i take the opportunity to thank you for this class i've been using since ci3 and that saved my life in many occasions :)

have a nice day

from datatables.

virtualgadjo avatar virtualgadjo commented on July 24, 2024 1

hi,
i wouldn't say lazy at all according to your kind of help 😀

and just for you to know i've set your previous tip with inherited variable and it works like a charm, i keep displaying 50 to 100 lines out of 356 (for now) with78 cols each, every cell havig its data-attribute in less than half a second and the whole table in less than one second, that will be even faster when choosing the cells that need to be edited

i sometimes use this column definition with datatables but the table i retreive will have more columns, the fifteen first won't change but due to the complexity of the tool i'm working on, instead of using a relational table between this one and another one containing 63 lines, for now... i alter the first one adding a col when an line is added to the second one, thus i can't define those cols in the datatables statement

i know could, writing dynamic js script in the page source code but i've tried and the result with three tables, two for the data and one for the relational thing (my usual way to work with mysql) makes the query far slower and thus the page too and i may need the page to reload after some cells modification which would make the tool a hell to use
using your tip, this server side table behaves like a simple table with 100 lines and a few cols already in the page :)

fortunately, back to the usual relational model for the other tables of this tool but even if i had to hit myself on the head to use mysql like a firebase db in this case, being an old php/mysql guy i'm happy to prove they stay as good and nearly as fast as react (or even one i prefer, vue js) and nosql dbs :)

thank again and a lot for your help :)

have a nice day

from datatables.

n1crack avatar n1crack commented on July 24, 2024

I don't recommend to edit all columns with php. It may have slow down your application. Instead I would use javascript for this.

However, you can pass the variables inside a anonymous function with "use" keyword.

foreach($dts as $sl) {
    $datatables->edit($sl, function($data) use ($sl ) {
        return '<span data-col="' . $sl . ' ">' . $data[$sl] . '</span>';
    });
}

from datatables.

n1crack avatar n1crack commented on July 24, 2024

I'm really glad to hear this.

I can provide you one more example to look. This is using colreorder plugin (I just chose this example, it doesn't needed for what I want to show), which allows the columns order positions can be changed, both the data and the search inputs can change accordingly.

https://datatables.ozdemir.be/colreorder

Btw, it is possible to define the columns by their names, they match with the data.

    // DataTable
    var table = $('#example').DataTable({
        "serverSide": true,
        "responsive": true,
        "colReorder": true,
        "ajax": "ajax/colreorder.php",
        "columns": [
            {"data": "TrackId"},
            {"data": "Name"},
            {"data": "Album"},
            {"data": "MediaType"}
        ]
    });

Moreover, you can order and edit columns like this:

            // DataTable
            var table = $('#example').DataTable({
                "serverSide": true,
                "responsive": true,
                "colReorder": true,
                "ajax": "ajax/colreorder.php",
                "columns": [
                    {
                        "data": "Name",
                        render: function (data, type, row) {
                            return '<span data-col="Name">' + data + '</span>';
                        },
                    },
                    {"data": "TrackId"},
                    {"data": "Album"},
                    {"data": "MediaType"}
                ]
            });

from datatables.

n1crack avatar n1crack commented on July 24, 2024

I know the example web pages are old, but I'm too lazy to update those :) just bear with them

from datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.