dgrid editor with a dijit.form.Select - dgrid

I have a column in my dgrid that uses a digit.form.Select.
var gl = {};
gl.coverTypeEditorData = [{label: "C", value: "C"},
{label: "F", value: "F"},
{label: "G", value: "G"},
{label: "S", value: "S"},
{label: "P", value: "P"}];
...
,editor({
'label': 'Type',
'field': 'TYPE',
'editor': Select,
'editorArgs': {
options: gl.coverTypeEditorData
}
}
)
The select drop down displays the correct value, but when it closes the value in the cell gets changed to whatever value was last chosen.
Row 1: Change the value to S.
Row 2: Has value C. I select the dd but do not change the value. Display changes to S. Change row event does not fire. The cell has a S displaying but its actual value is C, which will be the selected value if I open the drop down again.
What do I need to add to get the cell to display the correct value?

The answer was simple: The two constructors are not equivalent.
,editor({
'label': 'Type',
'field': 'TYPE',
'editorArgs': {
style: "width:35px;border: 1px solid green;",
options: gl.coverTypeEditorData
}
}, Select, 'click'
)

var args = targetColumn.editorArgs
targetColumn.editorArgs = function(){
args['options'] = lang.clone(data);
return args;
}
because dgrid sharing editorArgs
try lang.clone();

Related

Tabulator - problem with custom header filters and searchData()

I am using searchData() to count rows under different conditions for display to the user, without affecting the table itself. Specifically one col is "available" and I want to show how many rows there are depending on the filter criteria set, for both available and unavailable states. Most filters are normal default type header filters.
To do this I use the dataFiltered() callback. Inside the callback I get all the filters in a list, then do a count with and without an "available" filter added to the list. The problem is that I have one column with a custom header filter, and Tabulator complains if this one is active when searchData() is called. The custom filter works as expected in the table. Relevant code snippets are:
//table def
dataFiltered:function(filters, rows) { SetCounts(filters, rows) },
// col def
{title:"Sex", field:"sex", visible:true, hozAlign:"center", headerSort:false,
headerFilter:true, headerFilterFunc:customSexFilter,
},
// custom filter
function customSexFilter(headerValue, rowValue, rowData, filterParams) {
return (headerValue == rowValue) || (headerValue == "M" && rowValue == "N") || (headerValue == "F" && rowValue == "S");
}
// dataFiltered callback (simplified; one of two cases shown)
var availFilter = { field: "avail", type: "like", value: "A"};
function SetCounts(filters, rows) {
if (!table) return;
var filt = table.getHeaderFilters().concat(filters.slice());
var nAll = rows.length;
var fA = filt.slice();
fA.push( availFilter );
var nAvail = table.searchData(fA).length;
\$("#rowCount").html([nAll, '/', nAvail, 'A'].join(''));
}
The error that I get is Filter Error - No such filter type found, ignoring: function o(o)
and the filter itself shows as
field: "sex"
type:o(o)
value: "F"
I've studied the docs but can't figure out what I'm doing wrong. Or is this not supported? Version 4.6.

Google Slides API update table background color

basically I have table (8 rows x 3 columns) within the Google slides presentation, that I want to change background color to via the API.
First item of my list of rgb color values:
cons_data_lst[0][1][-1]
>>> [0.5882353, 0.7764706, 0.4862745]
My function to produce a request body:
def update_table_cell_colors(color_list):
req = [{
'updateTableCellProperties':{
'objectId': 'obj_id',
'tableRange': {
'location': {
'rowIndex': 1,
'columnIndex': 2,
},
'rowSpan': 1,
'columnSpan': 1,
},
'tableCellProperties':{
'tableCellBackgrounFill':{
'solidFill':{
'color':{
'rgbColor':{
'red': color_list[0],
'green': color_list[1],
'blue': color_list[2],
}
}
}}
}}} ]
return req
When I send batch update to presentation I receive the following error:
HttpError: https://slides.googleapis.com/v1/presentations/1dzxYYPuqTM3VhwaR93Ep2jj_9Y2NCkSBsVBnmN6lcOs:batchUpdate?alt=json
returned "Invalid JSON payload received. Unknown name
"table_cell_backgroun_fill" at
'requests[0].update_table_cell_properties.table_cell_properties':
Cannot find field.". Details: "[{'#type':
'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations':
[{'field':
'requests[0].update_table_cell_properties.table_cell_properties',
'description': 'Invalid JSON payload received. Unknown name
"table_cell_backgroun_fill" at
\'requests[0].update_table_cell_properties.table_cell_properties\':
Cannot find field.'}]}]">
Given a list of different rgb color values, how can I create a request body to update all columns (1 to 2) row (there are 8) text background color ?
Thank you.
How about this answer?
A1:
In this section, it explains about the reason of the error.
Modification points:
From the error message of Unknown name "table_cell_backgroun_fill" at 'requests[0].update_table_cell_properties.table_cell_properties', it is found that the property name of tableCellBackgrounFill is a spelling mistake. Please modify to tableCellBackgroundFill.
At updateTableCellProperties, the property of fields is required to be used. In your case, how about adding "fields": "tableCellBackgroundFill"? You can also use 'fields': '*'.
When these modifications are reflected to your request body, it becomes as follows.
Modified request body:
req = [
{
'updateTableCellProperties': {
'objectId': 'obj_id',
'tableRange': {
'location': {
'rowIndex': 1,
'columnIndex': 2
},
'rowSpan': 1,
'columnSpan': 1
},
'tableCellProperties': {
'tableCellBackgroundFill': { # Modified
'solidFill': {
'color': {
'rgbColor': {
'red': color_list[0],
'green': color_list[1],
'blue': color_list[2],
}
}
}
}
},
'fields': 'tableCellBackgroundFill' # Added
}
}
]
Before you use this script, please check the variables of color_list and 'obj_id',
A2:
In this section, it explains about the question 2 of Given a list of different rgb color values, how can I create a request body to update all columns (1 to 2) row (there are 8) text background color ?.
In your question, you say I have table (8 rows x 3 columns) at the top of your question. But at Given a list of different rgb color values, how can I create a request body to update all columns (1 to 2) row (there are 8) text background color ?, you say columns (1 to 2). I'm confused about this. So I would like to suppose as follows.
Your table has 8 rows and 2 columns.
You want to change the background color of all columns and rows with one color.
The sample request body is as follows.
Sample request body:
req = [
{
"updateTableCellProperties":
{
"objectId": "obj_id",
"tableRange":
{
"location":
{
"rowIndex": 0,
"columnIndex": 0
},
"rowSpan": 8,
"columnSpan": 2
},
"tableCellProperties":
{
"tableCellBackgroundFill":
{
"solidFill":
{
"color":
{
"rgbColor":
{
"red": color_list[0],
"green": color_list[1],
"blue": color_list[2]
}
}
}
}
},
"fields": "tableCellBackgroundFill"
}
}
]
rowIndex and columnIndex are the start cell.
"rowIndex": 0 and "columnIndex": 0 means the cell "A1".
rowSpan and columnSpan are the number of rows and columns.
"rowSpan": 8 and "columnSpan": 2 means 8 rows and 2 columns. By this, the background colors of cells "A1:B8" are changed.
If your table is 8 rows and 3 columns, and you want to change all cells, please set them as follows.
"rowIndex": 0, "columnIndex": 0 and "rowSpan": 8, "columnSpan": 3
If you want to change the special background color every cell, it is required to create the array of request body for each cell. Please be careful this.
Note:
This answer supposes that you have already been able to put and get values for Google Slides using Slides API.
References:
UpdateTableCellPropertiesRequest
TableCellProperties
If I misunderstood your question and this didn't resolve your issue, I apologize.

Can't get Tabulator select editor to work correctly

I'm new to the tabulator and am having trouble getting it to display droplist data in the correct format.
I have defined the column details thus:
{
title: "Status",
field: "Status",
width: 150,
headerFilter: "input",
editor: "select",
editorParams: {
listFormatter: populateStatusList
}
},
As you can see, the listFormatter calls function populateStatusList. This function builds an array of strings from an already-populated structure and returns the array.tostring() from the function.
The tabulator droplist does show the strings but horizontally on one long line and not vertically as I'd expect (i.e. it doesn't actually drop).
Can anyone help me?
Kind regards
The listFormatter should only be used to layout list items passed into the editor, the values for each of the items in the list should be passed into the values property
{title:"Gentlemen", field:"names", editor:"select", editorParams:{
listFormatter:function(value, title){ //prefix all titles with the work "Mr"
return "Mr " + title;
},
values:{
"steve":"Steve Boberson",
"bob":"Bob Jimmerson",
"jim":"Jim Stevenson",
}
}}
In the example above the list formatter will create a list of the titles passed into the values property, prepending each with the string "Mr"

Python: Tkinter: Delay When Inserting Into Entry Field Using Tree Item Property

I've got a bit of code that is suppose to change the text displayed in the entry fields depending on which item is selected in the tree view. I've bound the event to both the left mouse and up and down arrow keys and it's sort of working. Problem is the item in the tree that is currently selected isn't the value being displayed in the entry field. If there are three (5, 7, 4) values and the item with value 4 is selected, the entry field will display the item with value 7 in it. It's always one off. I hate to ask a question about this because I feel like the answer is so simple but I'm really at a loss. Here is my code.
# create GUI items to populate frames
self.create_menu()
self.create_edit_display()
self.albumDisplay = Label(self.editFrame)
self.create_import_display()
self.tree.bind("<BackSpace>", self.delete_insert)
self.tree.bind("<Button-1>", self.update_editFrame)
self.tree.bind("<Up>", self.update_editFrame)
self.tree.bind("<Down>", self.update_editFrame)
# selected track can be removed
def delete_insert(self, event):
self.tree.delete(self.tree.focus())
def update_editFrame(self, event):
trackInfo = self.tree.item(self.tree.focus())
print(trackInfo)
if self.tree.focus():
trackInfo = self.tree.item(self.tree.focus())
self.trackNumberEntry.delete(0, END)
#self.trackNumberEntry.insert(0, random.choice([1,2,3,4,5,6,7]))
self.trackNumberEntry.insert(0, trackInfo['values'][0])
else:
self.tree.focus_get()
Through my debugging I've noticed that every time I first click on the tree view I get something like.
{'tags': '', 'text': '', 'values': '', 'image': '', 'open': 0}
{'tags': '', 'text': 'IMPORT# 2', 'values': [6, 'Supersymmetry', '', 'Arcade Fire', 'Arcade Fire', 'Reflektor', '', '', 2013, '00:11:16', '', '', 'arcade_fire_reflektor_06_supersymmetry_.mp3', 'arcade_fire_reflektor.jpg', ''], 'image': '', 'open': 0}
It's that initial call that's messing up the order. I'm not sure why it's doing that before getting right into 'value''s values.
The simple solution is to bind to <<TreeviewSelect>> instead of binding to all the ways that the current item can be changed.
The reason your bindings always seem to be one behind is that they are. Custom bindings on widgets fire before the built-in bindings, and it is the built-in bindings which change the selected item. Thus, in your callbacks you are seeing the state of the tree before the selected item is changed.
For a longer explanation see https://stackoverflow.com/a/11542200/7432

How to add auto generated id on textField in Griffon?

I have tried a code about auto generating id. I want to try it on JTextField, but I don't know where i should put it.
Here is my code:
--PembelianController.groovy--
String generateID() {
String date = DateTime.now().toString("yyyyMMdd")
List list = findAllPembelian([orderBy: 'noNota', orderDirection: 'desc'])
Integer num = list.size()==0? 0: list[0].kode[12..-1].toInteger() + 1
return String.format("NT00%s%04d", date, num)
}
--PembelianView.groovy--
label('No Nota:')
textField(id: 'noNota', columns: 20, text: bind('noNota', target: model, mutual: true), errorPath: 'noNota')
errorLabel(path: 'noNota', constraints: 'wrap')
Well, it depends on when you want to do it. You can assign textField.text = generateID() at any time. You may assign the value during the binding
textField(id: 'noNota', columns: 20, errorPath: 'noNota',
text: bind('noNota', target: model, mutual: true, value: generateID()))

Resources