Infragistics UltraGrid Selected Cell Value - infragistics

I am using UltraGrid from Infragistics and facing a problem when selected a cell value. Whenever I select a cell value it shows as 0.000 as default. I want to show it as 0 or 1. I have already made the changes using the UltraGrid designer but for some reason it always displays 0.0000. The strange thing is that when the collection is bind to the Grid it only contains 0 or 1. Although the datatype for the column is decimal.

I found a solution to retrieve the current checkbox's value of Infragistics UltraGrid control :
private void grid_CellChange(object sender, CellEventArgs e)
{
// retrieve the current checkbox value
this.grid.Rows[e.Cell.Row.Index].Cells["Selection"].Value = !((bool)this.grid.Rows[e.Cell.Row.Index].Cells["Selection"].Value);
bool selVal = (bool)this.grid.Rows[e.Cell.Row.Index].Cells["Selection"].Value;
...
}

Seems like the problem was related to the Decimal type field bound to the column. I changed the field to Double and now it works fine!

Related

How to get value from listview in c++

I'm using C++ Builder 2010. I'm wondering, how can I get a value from ListView component? And is it possible get value only from 2-nd column(for instance).
I found a lot of information about adding values to ListView, not reading.
When you add a new item, the TListItems::Add() method returns a TListItem*. To access an existing item, you use the same TListItems to get a TListItem* for the desired item, eg:
// get the desired item by its index in the list...
TListItem *Item = ListView1->Items->Item[index];
In any given item, the 1st column is represented by the TListItem::Caption property, and subsequent columns are represented by the TListItem::SubItems property. So, just like when adding values using SubItems, you use SubItems to read the values, eg:
String value = item->SubItems->Strings[0]; // 0 = 2nd column, 1 = 3rd column, etc...

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

list of SelectedRows in QTableWidget

I have problem getting selected rows from QTableWidget. I have table like this:
[id] [ key ]
0 test
1 pass
I want to get every row's key values. I tried QTableWidget->selectedIndexes(); but it says it's protected and I can't access that. When I tried QTableWidget->SelectionModel->selectedIndexes, I don't know how to loop through list and get the key values. Do anyone know better way how can I do it?
Regards.
I'm assuming that you set the selection behavior of your table widget to select rows.
You can always access the so-called "selection model" of any item view/widget. QTableWidget inherits from QAbstractItemView, which gives you access to this special model. This model can tell you the selected rows as a list of QModelIndex, which can then tell you the row. Once you've got them, you can access the table content, in your case the text in the column with index 1 (key column).
static const KEY_COLUMN = 1;
QList<QString> selectedKeys;
QItemSelectionModel *selectionModel = ui->tableWidget->selectionModel();
foreach(QModelIndex index, selectionModel->selectedRows())
selectedIDs << ui->tableWidget->item(index->row(), KEY_COLUMN)->text();
Because you are using QTableWidget, you probably want to be calling selectedItems(). Your results will be based on what you have set the selection behavior to, via setSelectionBehavior()
When you have a list of items, you can specifically get the second column item (if it wasn't selected already):
QTableWigetItem *keyItem = table->item(anItem->row(), 1);
QString val = keyItem->text();

Get the index of the selected item of a datagridview combobox

I've searched a lot about the way of getting inedx of selected item of combobox inside datagridview but i have not found it !!
I can get the value of selected item by :
dataGridView1[j,i]->FormattedValue
But i can't get the index !
i've tried to cast DataGridView to DataGridViewComboBoxCell to use (SelectedIndex) property
DataGridViewComboBoxCell ^ t = dynamic_cast<DataGridViewComboBoxCell ^>(dataGridView1[j,i])
but there isn't any propery shown for "t" !
The DataGridViewComboBoxCell does not track the selected index.
You could play with its editing control, DataGridViewComboBoxEditingControl, to get the inner ComboBox, but it will be clumsy.
The simplest thing you can do is to lookup via IndexOf the cell Value in the collection of all possible values you use to initialize the DataGridViewComboBoxColumn.

Getting an UltraWebGrid selected row datakey when clicking on a cell

I have an Infragistics UltraWebGrid bound to a datasource; I am trying to allow the user to change the value of a few cells in the row, so I am trapping the CellClick event in code behind. While the event's argument gives me the cell key (which is the column name), I still need to have the selected row DataKey so as to make the change in the database. Anyone knows how to get that?
Thanks
Chris
You can use the igtbl_getCellById utility function to get the cell. Once you have the cell, you can get it's row and then it's key:
var cell = igtbl_getCellById(cellId);
var row = cell.getRow();
var key = row.DataKey
The following references may be helpful:
WebGrid utility functions
API documentation for the Cell object
API documentation for the Row object
Alan