Infragistics UltraWinGrid - How do you make a cell readonly but have a UltraCombo dropdown at the same time - infragistics

I have an UltraWinGrid with a column that I've tied an UltraCombo dropdown to as an EditorControl. I want the user to only select an option from this dropdown, I don't want them to type in text into the grid cell, or to cut/paste text either. How do I make the cell readonly, but at the same time allow the user to select an option from the dropdown? All the answers I've found online say how to disable the cell completely which is not what I want.
private void LoadItems()
{
DataTable dtt = new DataTable();
dtt.Columns.Add("Int", typeof(int));
dtt.Rows.Add(2);
dtt.Rows.Add(3);
dtt.Rows.Add(4);
uc.DropDownStyle = UltraComboStyle.DropDownList;
uc.SetDataBinding(dtt, null);
}
void myGrid_Grid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
myGrid.Grid.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
e.Layout.Bands[0].Columns["aaa"].ValueList = uc;
}

I think I figured it out. I used this and it seems to work so far:
e.Layout.Bands[0].Columns["aaa"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;

Related

How to freeze first column in Interactive grid in Oracle Apex

I have an interactive grid with source as : select header_1,header_2,header_3 from data;
I want HEADER_1 ,i.e. first column to freeze and others to scroll on display.
Also i am aware this can be done by end user by freezing the column, but can this also be done from back end?
How can this be achieved?
After you freeze column on IG, just got to Action/Report/Save and save it for all users.
To ensure that end user can't unfreeze column, go to IG column which you Froze, go to attributes in JavaScript initialization code and paste this code:
function(config) {
config.defaultGridColumnOptions = {
noHeaderActivate: true
};
return config; }
That's it.

Button to change selected records

I have an interactive grid with a bunch of records, and I want to set up a button on the page that changes one column in all records currently selected.
Running APEX 18.2, the IG has a whole bunch of columns and I want to change just one of them, but on a whole bunch of rows, so I do need a button.
The IG has ROWID as PK because the actual PK is assembled from 4 different columns.
I have spent some time googling this issue and have found a couple people with solutions:
http://thejavaessentials.blogspot.com/2017/03/getting-selected-rows-in-oracle-apex.html
This is the first, and simplest solution. But it doesn't return any rowid or anything like that, it returns the value in the first column.
Then I also found
http://apex-de.blogspot.com/2018/09/update-several-rows-in-tabular-form-grid.html
and
https://ruepprich.wordpress.com/2017/03/23/bulk-updating-interactive-grid-records/
Which are pretty similair and seem to be the best for me, but I get a Javascript error in the console: http://prntscr.com/n5wvqj
And I dont really know much Javascript, so I dont know what went wrong or how to best fix it.
I set up a Dynamic action on button click that executes Javascript and I have the selected element being the region named CUR_STAT.
var record;
//Identify the particular interactive grid
var ig$ = apex.region("CUR_STAT").widget();
//Fetch the model for the interactive grid
var grid = ig$.interactiveGrid("getViews","grid");
//Fetch the model for the interactive grid
var model = ig$.interactiveGrid("getViews","grid").model;
//Fetch selected records
var selectedRecords = apex.region("CUR_STAT").widget().interactiveGrid("getViews","grid").view$.grid("getSelectedRecords");
//Loop through selected records and update value of the AVT_OBR column
for (idx=0; idx < selectedRecords.length; idx++)
{
//Get the record
record = model.getRecord(selectedRecords[idx][0]);
// set Value for column AVT_OBR on "D"
model.setValue(record,"AVT_OBR", 'D');
}
The column named AVT_OBR is a select list with display values(DA, NE) and return values(D, N). But I tried having it be a text field and it didnt help.
I want to be able to select multiple columns and change the data in those entries.
If possible I would also like to be able to change data in such a way in a hidden column. Or if I could get all the ROWIDs for selected records and execute a PLSQL block with them.
Ended up with noone responding so I spent a lot of time and finally came up with a solution.
var g = apex.region('myIG').widget().interactiveGrid('getViews','grid');
var r = g.getSelectedRecords();
for(i = 0; i < r.length; i++) {
g.model.setValue(r[i], 'myColumn', 'Value');
}
For some reason none of the solutions I found had worked. But I learned from those solutions and made this simple piece of code that does what I need.
Also, I was wanting to set up so I could do this set value on a hidden column, I achieved this by just having the column visible and editable, but then when running the page I clicked on the column and hid it, and set the current view as the default report.
If anyone stumbles upon this question, I hope it helps.

Acumatica edit columns even if on Hold

The Purchase Orders screen(PO301000) has a Hold checkbox which when selected prevents the user from editing the columns from Document Details tab.
I want to edit the columns irrespective of the Hold checkbox is selected or not for the Open Orders.
You can accomplish this by using Automation Steps.
Select your Purchase Order screen, and on Step ID select "NL Open". (See below)
Then locate "PO Line" TableName with FieldName and unchecked the Disabled box. Then Save your changes.
Then let's say you want to modify the Qty field of the Grid, you can extend the POOrderEntry graph and on RowSelected event handler add your custom logic(and set enable the desired fields):
public void POLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
POLine line = (POLine)e.Row;
POOrder order = Base.Document.Current;
if (order == null || line == null || Base.IsExport) return;
if (order.Status == POOrderStatus.Open)
{
PXUIFieldAttribute.SetEnabled<POLine.orderQty>(sender, line, true);
}
}
Sample above would enable Qty field when POOrder is with Open Status (Hold unchecked). Here is another link to similar question involving Custom User Fields: How to enable a custom field on PO301000 when the PO is in Open status?

Initialize record on cell enter of XamDataGrid

Assume we have a XamDataGrid with 10 columns.
Column 1 is a XamComboEditor bound to a collection in the model
This can't be changed, the data is coming from a server and the combo's collection is based on different selections within the model so it's very dynamic.
Columns 2 - 10 are just normal alpha numeric fields
The problem:
When you enter a alpha numeric and start typing the model is initialized and everything is fine. However, if you go to the very last row, the non-initialized empty one, and click on the combo editor before entering any data into any of the other fields, the combo editor is empty.
Now I am well aware of why this is happening, it's clear that this is due to the model not being initialized yet. I'm just not sure the best method to fix this.
I would hope there is a property on the XamDataGrid that adjusts when the record is initialized but I've searched the Infragistics documentation and examples and I can't find anything.
There are events for:
EditModeStarting
EditModeStarted
EditModeEnding
EditModeEnded
private void OnCellEditModeStarting(object sender, EditModeStartingEventArgs args)
{
if (args.Cell.Field.Name == "TotalQuantity")
{
DataRecord record = args.Cell.Record;
if (record == null)
return;
MyGridEntry item = record.DataItem as MyGridEntry;
// Do a thing
}
}
You can also respond to the InitializeRecord event. It can fire for multiple reasons, such as cell editing, so check the state of your row model when responding to it. All these events are on the parent grid, not any FieldLayouts or Fields.
<i:XamDataGrid x:Name="myGrid"
InitializeRecord ="OnInitializeRecord"
EditModeStarting ="OnEditModeStarting">

Xamdatagrid howto get the current Cell on right click

here is the scenario I want ta achieve on some XamDataGrid
Some Cells may be selected in the grid - cells and not records
User right clicks on a cell in the grid
I would like to add the right clicked cell to the SelectedItems.Cells collection of the XamDataGrid if it was not selected before
BTW - I have no problem getting the entire Record, but what I require is the specific Cell.
any idea?
private void GridCellActivated(object sender, CellActivatedEventArgs e)
{
if (((UnboundField)((e.Cell).Field)).BindingPath.Path != null)
{
var _fieldPath = ((UnboundField) ((e.Cell).Field)).BindingPath.Path;
}
}