Tabulator - rowContextMenu - HowTo get which cell the mouse-rightclick is performed - tabulator

Is it possible to get which cell the right-click context menu is performed with rowContextMenu?
rowContextMenu gives the data for all cells in the row, but I have not found how to get which cell the action happens.
Using contextMenu could be an option, but I want to build the columns-setup serverside as json and load the columns with
table.setColumns(columnsJson)
Setting columns contextmenu as a function is not a valid json,
columns": [
{ "title": "", "field": "age", "sorter": "string", "headerSort": false, "contextMenu": cellContextMenu}
]
And setting the "contextMenu" as a "string" fails with: error: "Uncaught TypeError: o.forEach is not a function"
columns": [
{ "title": "", "field": "age", "sorter": "string", "headerSort": false, "contextMenu": "cellContextMenu"}
]
Any tips on getting which cell the menu is trigged with rowContextMenu?
Or is there maybe a different/better solution builtin in Tabulator?
Reason for building the column setup serverside is that I want to have different context menu based on type of cell-data, and it will vary based on selection by user.
BR
Bjorn

If you want to get the cell that is being clicked on then you need to use the Cell Context Menu instead as this is passed the cell component that has been clicked.
You would then need to assign the menu per cell but this is easy if you define it as an array outside the table and then reference it on each column definition using the contextMenu property:
//define cell context menu
var cellContextMenu = [
{
label:"Reset Value",
action:function(e, cell){
cell.setValue("");
}
},
]
//add header menu in column definition
var table = new Tabulator("#example-table", {
columns:[
{title:"Name", field:"name",contextMenu:cellContextMenu},
{title:"Age", field:"age",contextMenu:cellContextMenu},
{title:"Address", field:"address",contextMenu:cellContextMenu},
]
});

Related

Tabulator and send data to C#

When using tabulator-tables#4.9.3
Created 2 drop down list columns with editor: "select"
Used Code:
{title: "ProductID", field: "productID", sorter: "string", minWidth: 100, width: 150, sorter: "number", editable: Editable, editor: "number", validator: "required", hozAlign: "left", editor: "select", editorParams: { values: ProductIDSelect }, formatter: "lookup" , formatterParams: ProductIDSelect },
For Example: Products and Units. This type of drop down contain Name, ID.
After choose the name and press on save button will send the data from tabulator to C# to check all data type and Inserted to the table in database Image below.
enter image description here
Before sanded data I check data array with press right click on the page choose "Inspect" getting the below image
enter image description here
Shares indicate the number between "4" and "5" string type
When matching data by C# and finds that the Integer field type and string data are incorrect

What is the best way to add selectable space on a tabulator row that only has columns that grap the single click for edting?

I have a very simple table that is set up like this.
{
"tabulator": {
"rowSelected": "function(row){ this.send({topic:this.config.topic,ui_control:{'callback':'rowSelected','row':row.getData(), 'position':row.getPosition()}}); }",
"rowAdded": "function(row){ this.send({topic:this.config.topic,ui_control:{'callback':'rowAdded','row':row.getData(), 'position':row.getPosition()}}); }",
"rowDeleted": "function(row){ this.send({topic:this.config.topic,ui_control:{'callback':'rowDeleted','row':row.getData(), 'position':row.getPosition()}}); }",
"rowMoved": "function(row){ this.send({topic:this.config.topic,ui_control:{'callback':'rowMoved','row':row.getData(), 'position':row.getPosition()}}); }",
"rowUpdated": "function(row){ this.send({topic:this.config.topic,ui_control:{'callback':'rowUpdated','row':row.getData(), 'position':row.getPosition()}}); }",
"dataLoaded": "function(data) {var newData=[];data.forEach(function (datum) {var command = [datum.id, datum.torque, datum.duration];newData.push(command);});this.send({topic:this.config.topic,ui_control:{callback:'dataLoaded',data: newData}});}",
"dataEdited": "function(data) {var newData=[];data.forEach(function (datum) {var command = [datum.id, datum.torque, datum.duration];newData.push(command);});this.send({topic:this.config.topic,ui_control:{callback:'dataEdited',data: newData}});}",
"layout": "fitColumns",
"selectable": true,
"columns": [{
"field": "id",
"visible": false
}, {
"title": "Torque",
"field": "torque",
"editor": "number",
"editorParams": {
"step": 0.1
}
}, {
"title": "Duration",
"field": "duration",
"editor": "number"
}]
},
"customHeight": 12
}
I want to be able to select a row or rows with the standard click mechanism. However the rows only contain fields that have a numeric editor. The editor grabs all the single clicks on the row. I have implemented a really bad way of overcoming by introducing a column that has a title set to "Click me" and nothing else. This looks terrible. Does anyone has any suggestions on how I this can be done? I want to avoid using the the rowSelection formatter.
Thanks,
Roger
yes, in the Event, there is a target (or Source ... I forget). I use it on my custom headerFilters that have dropdowns, to distinguish between the user interacting with my dropdown, and Tabulator thinking the user has clicked in the header to move the column or change the sortOrder. If the target/source is my dropdown, I stopPropagation. If not, I let it through. In your case, you prolly want to stopPropagation if they are interacting with your editor.

Is this consistent behavior between "select" and "autocomplete" options of Tabulator?

to replace raw values I use "lookup" feature of Tabulator.
But "select" and "autocomplete" behaves differently
var country_list = {
1: "Germany",
2: "Ukraine",
3: "Canada",
};
//Build Tabulator
var table = new Tabulator("#example-table", {
height:"311px",
data: tabledata,
columns:[
{title:"ID", field:"id", width:40 },
{title:"Country", field:"country_id", width:130,
editor:"select",
editorParams:{values: country_list, },
formatter : "lookup",
formatterParams : country_list,
},
{title:"Country2", field:"country_id", width:130,
editor:"autocomplete",
editorParams:{values: country_list, },
formatter : "lookup",
formatterParams : country_list,
},
],
});
Try to edit Country and Country2 fields:
JSFiddle
"select" displays label, but "autocomplete" displays raw value.
Is this behavior consistent?
If yes, how to force Tabulator to hide raw value?
This is a bug, a fi has been pushed to the 4.2 branch which should be released shortly

Parameter whole range or table in Excel Power Query

I have an Excel sheet with a column containing IDs of items I want to retrieve
||ID||
|123|
|124|
|125|
The API I am calling can take an array of IDs as input (e.g. https://API.com/rest/items?ID=123&ID=124&ID=125....(up to 50))
and returns one JSON.
"data": [
{
"id": 123,
"fields": {
"name": "blah blah",
"description": "some description",
}
},
{
"id": 124,
"fields": {
"name": "blah bli",
"description": "some description",
}
},
{
"id": 125,
"fields": {
"name": "blah blo",
"description": "some description",
}
},...
]
}
I would like to load data from this JSON in another table or sheet.
||ID||Name||
|123|blah blah|
|124|blahblo|
|125|blahbli|
I would know how to parameterise the query by referencing single cells, but if I am retrieving 100+ items, that's a lot of work.
Can't I somehow build a query that gets each value (ID) from the table or range in one simple move?
--edit1--
Found another API endpoint where I can provide an array of IDs. (before I thought it was only possible to send one ID per request to retrieve one JSON at a time)
--edit2--
Maybe I can concatenate all IDs into the request URL already in an Excel cell and parameterise just based on that one cell. (still experimenting)
If you've got the JSON for each ID, then you just need to pull out the name part.
For example, if you have a column [JSON] with the JSON for each ID, then you can create a custom column using Json.Document([JSON])[data][name] as the formula.
You can likely combine pulling the JSON and parsing it into a single step if you'd like.

get values of select option in angular 4+

Hi I have a question how to get the values from list in a select option.
I have this array
{
"C_ID": "Item044",
"Descripcion": "Item 1",
"ID": "044"
},
{
"C_ID": "Item045",
"Descripcion": "Item 2 ,
"ID": "045"
},
{
"C_ID": "Item046",
"Descripcion": "Item 4",
"ID": "046"
},
{
"C_ID": "Item047",
"Descripcion": "Item 5",
"ID": "047"
},
and I get this values in a select option with NgFor but I need when selected for example Item 1 get the ID and C_ID in a input text automatic
and I get this values in a select option with NgFor but I need when selected for example Item 1 get the ID and C_ID in a input text automatic
Wire an ng model to the select input. And then wire the backed field to the input. Now when the select changes the input text should change.

Resources