Git Product home page Git Product logo

Comments (3)

tabalinas avatar tabalinas commented on July 21, 2024

Column reordering w/o drag and drop is that simple: change the option of grid where fields brought in desired order (the order itself could be with any external ui):

$("#jsGrid").jsGrid("option", "fields", fields);

The DnD column reordering could be implemented with jquery ui.sortable.
Just add following onRefreshed event handler to grid config:

    onRefreshed: function(e) {
        var $headerRow = $("#jsGrid .jsgrid-header-row");
        var $headerCells = $headerRow.find("th");
        var fields = e.grid.option("fields");

        $.each(fields, function(index, field) {
            $headerCells.eq(index).data("JSField", field);
        });

        $headerRow.sortable({
            axis: "x",
            placeholder: "header-cell-placeholder",
            start: function(e, ui){
                ui.placeholder.width(ui.helper.width());
            },
            update: function(e, ui) {
                var fields = $.map($headerRow.find("th"), function(cell) {
                    return $(cell).data("JSField");
                });

                $("#jsGrid").jsGrid("option", "fields", fields);
            }
        });
    }

Here on each grid refresh we add references to fields in header cell data, and set the grid option fields on sortable update. Here is working fiddle: http://jsfiddle.net/tabalinas/780bfqkk/

Since it's not that complicated to implement column reordering from outside, I think it's enough for the moment to add a demo with column reordering. Build-in column reordering functionality, may be postponed for a while.

from jsgrid.

ViniH avatar ViniH commented on July 21, 2024

I'm having a little difficulty implementing this column reordering - we use a promise to fulfil the data (which comes from a database asynchronously) and this implementation is throwing a max call stack exceeded error.

I've just started looking at this so if you have any insight it would be appreciated.

from jsgrid.

blysons avatar blysons commented on July 21, 2024

Hi tabalinas ! Is it possible to have the whole column dragging (not just the header) when dragging a column ?

from jsgrid.

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.