Boolean column(Check box) cell in Infragistics UltraGrid should be disabled based on a condition in InitializeRow event - infragistics

In Infragistics Ultra Grid I have to disable a Boolean (Check box) cell based on a condition in Initialize Row event
PS: I don't want entire column to be disabled. Just only cell should be disabled (cell which contains check box should also be disabled).
I kept code like below
e.Row.Activation = Activation.NoEdit
This code is disabling all the cells in ultra grid row. But a Boolean checkbox which is present in a cell is not getting disabled.

try something like:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{ // deactivate boolean in cell 0
//ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation =
// Infragistics.Win.UltraWinGrid.Activation.Disabled;
e.Row.Cells[0].Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;
}
Other choices available beside Disabled are: ActivateOnly, AllowEdit, and NoEdit
You can always come back and activate it.

Here is another idea. Instead of a boolean cell, make it a System.Drawing.Bitmap and create your check boxes, checked, and unchecked.
and then create/modify an image(s) for disabled.
On the cell click event, change the cell image according to your needs. If need be, create an additional hidden column to store the state/value of the cell. This is something I did when I created/translated a Java version of my c# application to run on other platforms and it worked out great. (Feel free to use these images if it helps)

Found the root cause. In base class there is one mouse down event due to which checkbox in ultragrid is being enabled. Even though if i kept logic like this e.Row.Activation = Activation.NoEdit.
Thank you all for your help.

Related

How to add a new record into an interactive grid using IG methods then set column's value using $s() api?

I am using Oracle Apex 18.2.
I have an interactive grid and a custom button to add a new row to the IG using,
apex.region("myRegionStaticId").widget().interactiveGrid('getActions').invoke('row-add-row'); then set a column's value using, $s("myColumnStaticId","2");. When I try it, it adds the first row without setting any columns' values and starts setting the value from the second row on. Even using selection-add-row or insert-record, there is always something with the first row. Here is a sample,
[https://apex.oracle.com][1]
ws = ESLAM_WS
user = forhelp
pwd = forhelppwd
app = TEST
page = Add Row on top of an IG.
After a lot of talking and testing, I've found that $s with setTimeout isn't very reliable. I've set up page 7 again to demonstrate.
If you click the Rowaddrow button twice in rapid succession (the second time before the first setValue returns), the second row will not be initialized. I'll show you a workaround for this below, but you'll
If you lower the setTimeout to, say, 10 ms, and try focusing in the Expiry Date column before clicking the Rowaddrow button, you'll find it doesn't work. This means that, while the setTimeout of 100 ms works now, it could break in the future if the IGs internal logic changed. Unlikely but who knows.
For the moment, I would say that $s can only be reliably used to set a column value in an IG for the active row. When the row-add-row action adds a new record, it does make it active, but that is done asynchronously via setTimeout. This is because the IG is based on the flyweight pattern and there are a number of async (setTimeout based) heuristics that are built in to handle focus and blur events to correctly enable and disable rows and cells as needed.
I've found the following to be the most reliable solution. Unfortunately, it's more complex than what you had before - but it was the only way I could wrangle it all together. Feel free to use it or not. See page 8 for an example.
Right-click the custom Rowaddrow button and select Create Dynamic Action. Set the Name of the DA to rowAddRow button clicked. The When settings will automatically be configured for the click event on the button.
Select the action for the new DA. Set Action to Execute JavaScript and enter the following JavaScript in the Code attribute.
addRowClicked = true; // Global used to distinguish custom button click
this.triggeringElement.disabled = true; // Disable button to serialize access
apex.region("KITCHEN_SHARE_DTL").widget().interactiveGrid("getActions").invoke("row-add-row");
Create a new Dynamic Action and set the Name to New row initialized. In the When section, set Event to Row Initialization [Interactive Grid], Section Type to Region, and Region to KITCHEN_SHARE_DTL.
Under Client-Side Condition, set Type to JavaScript expression and enter the following code in JavaScript Expression (which ensures the DA only fires for the click of the Rowaddrow button):
addRowClicked === true
Select the action for the new DA. Set Action to Set Value, Set Type to Static Assignment, and Value to 2. In Affected Elements, set Section Type to Column(s) and Column(s) to INGREDIENT_ID. This will replace the static assignment that was being done with $s. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set the Action to Set Value, Set Type to SQL Statement, and enter the following code in SQL Statement:
select MIN(EXPIRY_DATE) from stock
where ingredient_id = TO_NUMBER(:INGREDIENT_ID);
Set Items to Submit to INGREDIENT_ID and disable Escape Special Characters. In Affected Elements, set Selection Type to Column(s) and Column(s) to EXPIRY_DATE. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set Action to Execute JavaScript Code and enter the following JavaScript in the Code attribute.
addRowClicked = false; // Unset the global
$x('ADD').disabled = false; // Enable the button
Change the following code:
$s("INGREDIENT_ID","2");
with the following one:
setTimeout(function(){ $s("INGREDIENT_ID","2"); }, 100);
It seems that the IG needs a little time to render the new row before you are able to change any value.

Formula help on IF ELSE on Smartsheet

I want to have a condition where IF Delivered column checkbox is checked, then that whole row will be deleted. Is that feasible?
How can I start with it?
Formulas can't change the condition of an item (like a row), only the value in a cell. So, in other words, you can't delete a row with a formula.
You "could" do this with an external script using the Smartsheet API, but you'll want to take situations that #Ken White mentioned in the comments into account. Your script should make sure that there is a way for users to recover the deleted row if the box is checked by mistake.
There are a couple of ways this might be possible. If you set up a default filter on a sheet to always load rows where complete box is unchecked, then, if you checked off a task or two and reloaded the sheet those tasks would not be visible the next time it loads.
To do this:
Create a new filter.
Title it and check the Share Filter checkbox
Set the criteria to the checkbox is unchecked
Then click okay
Save the sheet to save the shared filter.
Click on SHARE
Scroll down and click edit next to the default view
Set the filter to new filter you saved
Save.
Check off some boxes and save the sheet.
Reload the sheet and the completed items will not be visible.

C++ QT: QTableWidget; how to let the user select text in a cell but not edit it

I am using a QTableWidget and I have a requirement that the user is able to highlight specific text in a cell, but the cell contents should not change if the user accidentally erases or modifies some cell contents. I was thinking that the simplest way to accomplish this would be to just ignore any edits that occur when the user finishes editing a cell. Any ideas how to do this?
Using C++ 98 and QT
You can access the table widget items and modify their properties You want to disable the Qt::ItemIsEditable flag :
QTableWidgetItem* item;
item->setFlags(item->flags() & ~(Qt::ItemIsEditable));
A good way is to set the item prototype before inserting cells into the table. Right after creating the table
const QtableItem* protoitem = table->itemPrototype();
QtableItem* newprotoitem = protoitem->clone();
newprotoitem->>setFlags(item->flags() & ~(Qt::ItemIsEditable));
table->setItemPrototype(newprotoitem);
Now every new cell in the table will have the editable flag disabled. If the user double click it will not open the text edit in the cell.
ps: Do not delete newprotoitem afterwards.
This is late, but for follow-on searches:
The best way to do this is to subclass a delegate (QStyledItemDelegate is the least problematic - no abstract virtuals).
In the delegate, override 'setModelData()' to a stub. The editor will still come up, and you can still change its contents, but the edit won't 'take'. As soon as you leave the cell, it will revert to its original contents.
If you want to prevent the editor from accepting keys (QLineEdit), override 'createEditor()' in your delegate. Call the base class to create an editor, check its type, and then install an event filter on the editor to reject keypress/keyrelease events.
Return the editor in your override.
Works for me, although I did have to const_cast 'this' (to non-const) to install the event filter.

Ultragrid entire column selection when header is clicked

This might seem a very easy problem but I am stuck and can't find a way out of it. I am using ultragrid in my form with several columns. My issue is when I am trying to click on the column header I am expecting my entire column to be selected but it doesn't. I assumed the SelectTypeCol is the property for my column selection but it did not work either. I also tried to add each column to Selected.Columns collection like this UltraGrid1.DisplayLayout.Bands(0).Columns(i).Header.Selected = True but it didn't work for me either. I believe Selected is only available during runtime but not at the design mode.
So if there is an easier way to make this work, please let me know.
Thank you
You are looking for the property HeaderClickAction
grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select
This will automatically flip the selection state of the entire column as Selected (or Delected) when you click on the header. Of course this means also that you loose the ability to automatically sort on all columns
You can programmatically set the Selection state of a column with code like this (C#)
grid.DisplayLayout.Bands[0].Columns["youColumnKey"].Header.Selected = true;
this will permit to leave the HeaderClickAction property to SortSingle or SortMulti, but you have to handle the situation using code and appropriate events
You need to have an InitializeLayout event on your grid. in this event you need to set the chekboxsynchronization to default and it should work here is sample code
private void ultraGrid1_InitializeLayout(object sender,
Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
e.Layout.Bands[0].Columns.Add("CheckBox");
e.Layout.Bands[0].Columns["CheckBox"].Style = ColumnStyle.CheckBox;
e.Layout.Bands[0].Columns["CheckBox"].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.WhenUsingCheckEditor;
e.Layout.Bands[0].Columns["CheckBox"].Header.CheckBoxSynchronization = HeaderCheckBoxSynchronization.Default; <-- make sure it is set to default here
}

QTableView re-focus the view to specific column

I have a QTableView with 80+ columns displayed in it. The subclass i have created for QTableView allows has functionality for the standard table stuff i wanted e.g order by columns move columns and rows hide column and rows etc.
However the problem i have is the view's focus. lets say you have all the data in the table, you scroll all the way to the right so you are looking at columns 70-80 (assuming 10 columns fit on the screen at once) if i click the header of row 80 (to order by column 80) the table reorders (as expected) however it also jumps the view to the last focused cell (which as far as i can tell is the cell that was last clicked)
What i want to do is not necessarily refocus on the column that was clicked because this might still change the view what im looking for is to just keep the view's focus exactly as it is instead of having it jump back to where the last clicked cell was?
Is there some flag im missing for focus policy or will i need to get the current view and set the view back to that view after mouse clicks that reorder the table and if so how could this be done.
Im aware i have provided no code for this question but it doesnt seem there is any needed since its not a bug im looking to fix more of a feature im unaware of, if you want to see any just comment
EDIT:
Im using a QSortFilterPorxyModel, this seems to get set once (when i call this->setSortingEnabled(true); after the initial call to this on contruction my table model never calls sort again. I have a slot linked to the header clicked signal, and i set the scroll bars to scrollTo() to the index clicked, but i think the sort is happening after this so it does nothing, any idea of what signal are emitted after sorting so i can catch them and then set the view back maybe?
thanks
Before you do your sort, store the current values for where the scroll bars are with
int vPos = yourQTableView->verticalScrollBar()->sliderPosition();
int hPos = yourQTableView->horizontalScrollBar()->sliderPosition();
then after the sort, set it back
yourQTableView->verticalScrollBar()->setSliderPosition(vPos);
yourQTableView->horizontalScrollBar()->setSliderPosition(hPos);
The signals you are looking for are signals of QSortFilterProxyModel inherited from QAbstractItemModel:
layoutAboutToBeChanged()
layoutChanged()
I couldn't reproduce your symptoms by creating a QTableWidget, filling it up with random stuff, and then sorting a particular column. The selected cell stays selected, but does not become visible if it has scrolled off screen.
So the question is, what is causing the behavior you're seeing. It sounds as though scrollTo() is being called by some other function. Since that's a virtual function, I would override it with a pass-through function and see when it's getting called.