Xamdatagrid howto get the current Cell on right click - cell

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;
}
}

Related

How can Google Spreadsheet use "onedit" to change cells with if statements?

I'm new to Google script and hoping someone here could answer this.
I have 7 columns and each one has a drop down box so we can select a status "Ready", "Approved", "Waiting" etc.
There will soon be over 500 rows of statuses so ideally I would like to have a function on each column to automatically set the status of the column after it.
Example Cells:
Ready|Waiting|Waiting|Waiting|Waiting|Waiting|Waiting
When the first task is Approved, the cells should look like this:
Approved|Ready|Waiting|Waiting|Waiting|Waiting|Waiting
In the above example, the first cell should be clicked "Approved" by the user from the drop down list. Then the script should read the cell edit, and switch the next cell from "Waiting" to "Ready"
I am looking at the script route as I need to have the drop down cells clickable. If I put a function onto the cell itself, I lose the drop down options.
Any help with this would be really awesome!
Thanks in advance!
You may want to check this YouTube video and this transcribed code can be tweaked to suit your needs:
function setDataValid_(range, sourceRange) {
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange, true).build();
range.setDataValidation(rule);
}
function onEdit() {
var aSheet = SpreadsheetApp.getActiveSheet();
var aCell = aSheet.getActiveCell();
var aColumn = aCell.getColumn();
if (aColumn == 1 && aSheet.getName() == 'Worksheet') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
}
And for additional insights, you may want to also see this thread.

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">

Prevent selected item from going out of view in QListView

I am using a QListView with only single selection and selection changes handled by the up and down arrows. Everything is working as expected with one minor issue. If many items are added to the top of the list then the currently selected item risks moving down and out of view. Is there any way to detect when this happens? Thanks.
I found solution, but first of all I try to do dimilar thing, I run timer and every 2 second I insert new row to the begin of list and try to detect, is selected item still visible?
//somewhere in the constructor, it is not important
ListModel = new QStandardItemModel();
ui->listView->setModel(ListModel);
Now when I want to insert new row , I wrote code, which checks is the item visible
QStandardItem* Items = new QStandardItem(QString::number(qrand()%100));
ListModel->insertRow(0,Items);
// here we get rect of current selected item
QRect rec = ui->listView->visualRect(ui->listView->currentIndex());
//here we get all listView region, convert it to rect and check is our listView
//contain selected item
if(ui->listView->viewport()->visibleRegion().boundingRect().contains(rec))
{
qDebug() << "visible";//all good
}
else
{
qDebug() << "not visible";//not good, we need do something
//you want to detect it, so you get!
//now you know that item "runs away from you"
//and you can do some actions
someAction();
}
I test it on my computer, when I can see item, I get visible word, when item tries "run away from me" I get not visible
I hope it helps.

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

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;

How do I access the child rows of an Infragistics Web Grid row?

I need to modify the contents of the child rows of a hierarchical Infragistics web grid when it is expanded. I can get the parent row from "e.Row" in the following code. But how do I get its child rows to edit?
For that matter, how can I get the rows from any band other than band 0?
protected void CustomerActivitiesGrid_ExpandRow(object sender, RowEventArgs e)
{
UltraGridRow expandedRow = e.Row;
}
It's quite easy, just access the row's rows.
foreach(UltraGridRow childRow in e.Row.Rows)
{
// your code
}
Subsequently, you can access the children rows of those rows the same way
childRow.Rows
You can also access a specific row using its key
UltraGridRow specificChildRow = e.Row.Rows.FromKey("ChildRowKey");