From 0c241ba61060c7b817db9a9d5a3086b6a0458fb0 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sat, 7 Jan 2023 17:00:08 +0000 Subject: [PATCH] provided callback for rowMoved --- README.md | 17 ++++++++++------- etable.js | 7 +++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 45563c0..192e8b3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Options can be { "movableColumns": true, + "movableRows": true, "resizableColumns": true, "selectable": 5, "responsiveLayout": "collapse", @@ -32,13 +33,14 @@ Options can be Columns can be -[ {title:"Name", field:"name", editor:"input"}, - {title:"Task Progress", field:"progress", align:"left", formatter:"progress", editor:true}, - {title:"Gender", field:"gender", width:95, editor:"select", editorParams:{values:["male", "female"]}}, - {title:"Rating", field:"rating", formatter:"star", align:"center", width:100, editor:true}, - {title:"Color", field:"col", width:130, editor:"input"}, - {title:"Date Of Birth", field:"dob", width:130, sorter:"date", align:"center"}, - {title:"Driver", field:"car", width:90, align:"center", formatter:"tickCross", sorter:"boolean", editor:true} +[ + {title:"Name", field:"name", editor:"input"}, + {title:"Task Progress", field:"progress", align:"left", formatter:"progress", editor:true}, + {title:"Gender", field:"gender", width:95, editor:"select", editorParams:{values:["male", "female"]}}, + {title:"Rating", field:"rating", formatter:"star", align:"center", width:100, editor:true}, + {title:"Color", field:"col", width:130, editor:"input"}, + {title:"Date Of Birth", field:"dob", width:130, sorter:"date", align:"center"}, + {title:"Driver", field:"car", width:90, align:"center", formatter:"tickCross", sorter:"boolean", editor:true} ] Pass input data in msg.payload. Note that options and columns can also be passed in via msg. @@ -54,4 +56,5 @@ CallBacks handled are : If the cell has editor = true, a message is sent with "callback : cellEdited" If the cell has editor = false, a message is sent with "callback : cellClick" + If rows are movable, a message is sent with "callback : rowMoved" diff --git a/etable.js b/etable.js index 3e8dbd0..b5d43e3 100644 --- a/etable.js +++ b/etable.js @@ -101,7 +101,14 @@ module.exports = function (RED) { opts.cellEdited = function(cell) { $scope.send({topic:cell.getField(),callback:"cellEdited",payload:cell.getData(),options:opts}); }; + } + + if( opts.movableRows){ + opts.rowMoved = function(row) { + $scope.send({callback:"rowMoved",payload:{row: row.getData(), position: row.getPosition()},options:opts}); + }; } + var table = new Tabulator(basediv, opts); }; $scope.init = function (config) {