So basically I want to get a button to change color, but I won't be pressing this button, it is an idle button. Other buttons are supposed to change this by clicking them.
I want to pass the view into a parameter and then use that view to change the backgrounds color.
changeColorBlack(R.id.light);
this is the line I have in mind on how to pass it, but it keeps saying it is an int and cannot be passed. Is there another way to do this, or even a picture that is easily changed from color to color with out having to worry about making it a useable view in the class?
create function p1() returns INTEGER DETERMINISTIC NO SQL return #p1;
create view h_parm as select * from sw_hardware_big where unit_id = p1() ;
Then you can call a view with a parameter:
select s.* from (select #p1:=12 p) parm , h_parm s;
Related
I wish to have a list of text items in a PySimpleGUI that I can update later. That is, I want to have a key for the list. This might be vertical or horizontal, and I do not know how many items there will be.
I end up with different use cases, but the current one is to make a single line of text items with different colors. Other times, I need to write and update a customized table, just different enough that the table widget does not work.
Conceptually, I want to do something like this:
layout = [ [sg.T('Titles and Things')], sg.ListThing(key='-data-', [[]]) ]
so that I can:
window['-data-'].update(values=[ [sg.T(v, color=c)] for (v,c) in my_data ])
Another, invalid syntax, way of saying what I want is to use [key="-data-", sg.T('Item1'), sg.T('Item2')].
Is this possible?
You can update individual layout elements but you cannot dynamically change the layout itself.
It is possible to create 2 or more elements, whereby only one of them is visible, and switch them later as needed. Or you can close and re-create the window with another layout. Or combine both approaches.
An example of switching layouts:
def change_layout():
left_col_1 = sg.Column([[sg.Text(f'Text {i}') for i in range(4)]], visible=True, key='col_1')
left_col_2 = sg.Column([[sg.Text(f'Text {i}')] for i in range(6)], visible=False, key='col_2')
visible_1 = True
layout = [[sg.Column([[left_col_1, left_col_2]]), sg.Button('Change layout', key='change')]]
window = sg.Window('window', layout=layout, finalize=True)
while True:
event, values = window.read()
print(event)
print(values)
print(visible_1)
if event in ('Exit', sg.WIN_CLOSED):
break
if event == 'change':
window['col_1'].update(visible=not visible_1)
window['col_2'].update(visible=visible_1)
visible_1 = not visible_1
Please notice that the alternative layouts for the left part (left_col_1, left_col_2) need to be enclosed in a container (column, frame) to keep their position in the window in the moment they are invisible.
I'm trying to figure out if this is possible in Oracle APEX interactive grids. I'm wanting to insert a string of text like "Y" into a cell simply by clicking the cell. I'm trying to avoid using a checkbox.
Blockquote
Please follow the below steps to achieve the desired result
Paste the below JavaScript code in Function and Global Variable Decleration:
function fSwitch(ptext) {
if(ptext == 'Y') {
return ("");
}
else {
return 'Y'
}
}
Make the Interactive Grid Editable
Change Column Type of the column that you want to insert a string to "Text Field".
Paste the below code in the Advanced -> Custom Attributes of the column that you want to insert a string
onclick="javascript:this.value=fSwitch(this.value)"; onkeypress="return false;"
How this works:
On focus of the column cell,
If the cell is empty 'Y' will be entered,
If the cell contains 'Y' then the cell value becomes NULL;
There's a built-in "Switch" type for interactive grids which can be used to create yes/no columns. Would that work?
For an example, go to the App Gallery and install the Sample Interactive Grids app. Run it and navigate to Editing > Other Column Types, then look at the "On Leave" column.
Is there any way i can hide HOT columns from javascript?
The requirement is such that the column to hide will come as a parameter in javascript and based on that the respective column will show hide accordingly.
The HOT has rowHeaders and colHeaders and the data with 20 columns.
Please advise.
OUTDATED SOLUTION
Ok I founnd a possible solution. I tested it out on my own system but it's actually quite simple.
You should be using a customRenderer in your columns option. Read up about this if you aren't already. The idea is that you're giving each cell its own renderer. In this custom function, you can do something like this:
var colsToHide = [3,4,6]; // hide the fourth, fifth, and seventh columns
function getCustomRenderer() {
return function(instance, td, row, col, prop, value, cellProperties) {
if (colsToHide.indexOf(col) > -1) {
td.hidden = true;
} else {
td.hidden = false;
}
}
}
What this renderer does is hide the cells that the var colsToHide specify. All you do now is add a DOM element that lets the user pick which and so every time the table gets rendered (which happens basically after any change, or manually triggered need be), the cells in the columns specified will be hidden, keeping the data array intact like you described. And when not in colsToHide they are re-rendered so make sure you get that working as well.
Here I implemented it with very basic functionality. Just enter the index of a column into the input fields and watch the magic happen.
http://jsfiddle.net/zekedroid/LkLkd405/2/
Better Solution: handsontable: hide some columns without changing data array/object
I need to select a specific row in kendoGrid but NOT by data-uid (as data-uid is changed when the grid dataSource is loaded again) but by the row itemID. I saw posts but they only select the row by uid which is not what I needed, I actually need to restart the HTML5 application and when grid is loaded, a specific item should be selected. This is what I've been seeing
Demo: jsfiddle.net/rusev/qvKRk/3/
e.g. the object has OrderID as ID, and every time the grid is loaded, it will be the same, unlike uid, I want to know how will I be able to select a row with OrderID, instead of uid.
You cam mix row itemID and data.uid, I guess.
var grid = $("#Grid").data("kendoGrid");
var dataItem = $("#Grid").data("kendoGrid").dataSource.get(itemID);
var row = $("#Grid").data("kendoGrid").tbody.find("tr[data-uid='" + dataItem.uid + "']");
Going along with what umais has mentioned, the better approach, since there is no built in functionality for this as of yet, would be to iterate through all the records to find the one you need. The function that I built will work even if there are pages of data. The only other way that I can think of doing this would be do do a secondary ajax call; But this works well. Note that i haven't tested it with more than 2000 records.
var dataGrid = $("#GATIPS").data("kendoGrid").dataSource;
var numOfRows = dataGrid.total();
var currentPageSize = dataGrid.pageSize();
dataGrid.pageSize(numOfRows);
var dataGridData = dataGrid.data();
for (var i = 0; i < numOfRows; i++) {
if (dataGridData[i].uid == e)
return dataGridData[i];
}
dataGrid.pageSize(currentPageSize); // reset the view
e is the UID. However this can be substituted for what ever variable you need just replace the check.
a work around that I managed to have, was to go through all rows and check which row model has that ID equal to the parameter, and then get that row data-uid and select the item through data-uid. It's working fine for me, since there were no suggestion, it's the better answer for now.
Well, accordingly to what I have done (and worked for me), and even though the work around isn't the prettiest, set one more Column, with your model id and with ClientTemplate then create any html object (div in my case) inside it give it a html id of your id, so when ever you need it, you just have to go and look with something like:
grid.dataItem($("td div#id").closest("tr"));
Because remember that the dataItem method is waiting for a selector then you get your selectedItem as regular one.
EDIT:
I forgot to say, that you should (or could) use the style property
display:none
If you don't want to display that col.
ok, here is the story...
I have 3 textfield for user to select....
[textfield A][textfield B][textfield C]
and a confirm button, the user need to add three textfield, after that , the user need to click the confirm button.... but based on different select order, the result is different, for example:
A>B>C, I will show red.
When the user select in this order:
B>A>C I will show green.
When the user select in this order:
C>B>A I will show the color blue....
based on different user select order, it will show different color....
But the question is, when I add more and more textfield, how can I implement this logic?
First, I design to have an array , when the user select one textfield, I store the textfield id to array, when user select the second one, I will store in the array, until the user click confirm, I read back the array to display the color....
But I think it will become very big & messy when more and more textfield is added, any better ideas? Thank you.
It's a bit of a hack, but what I'd be inclined to do is store the selections in a string that gets appended to each time (starting with empty string of course), trimming to the rightmost x characters. Then you can do a simple switch/case statement to determine the color. For example (C# fragments, sort of):
string selectStr = string.Empty;
void Select(string btn) {
selectStr += btn;
selectStr = selectStr.Remove(0, btn.Length - 3);
}
void Confirm() {
switch (selectStr) {
case "ABC" : /* make red */ break;
case "BAC" : /* make green */ break;
// etc.
}
}