Ultragrid entire column selection when header is clicked - infragistics

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
}

Related

Using jqGrid I need to Show a Hidden Column Based on UserData Parm

Using jqGrid 4.15.6-pre - free jqGrid
I am wondering why the following code will not show the specified column.
var cm = $('#nrtslist').jqGrid('getColProp','override');
cm.hidden = false;
This can't be done this way.
All the concept of the grid is that you can read the properties of colModel or any other grid option, but changing it does not mean that it will change something. With other words something must happen in order to change the property.
These properties describe the current status (in most cases) or this is a consequence, not a cause.
To change something in grid you will need to use the appropriate method or do your own one.
In your case you will need to use the showCol or hideCol methods
$('#nrtslist').jqGrid('showCol','override'); // this will show the column
$('#nrtslist').jqGrid('hideCol','override'); // this will hide it.

How to hide the first column of a wxListCtrl in wxWidgets?

The context
In a wxWidgets (version 3.0.2) C++ application, I am trying to hide the first column of a wxListCtrl.
I did not find a member function to do this so I tried to set the width of the column to 0:
myListCtrl->SetColumnWidth(0, 0);
first argument being the column ID and second one the width in pixels (wxListCtrl documentation).
After running the program, the header of the first column is hidden as I wanted but the data of each row of the first column overlaps the data of each row of the second column (which is not hidden). It is obviously not what I want. The header and the data of the first column should be hidden.
The question
In wxWidgets 3.0.2, is there a way to hide the first column (header and data of each rows) of a wxListCtrl?
I don't believe you can. You have a few options.
Delete the column using DeleteColumn(int columnIndex). You aren't losing any data, just the display of it, so you can always re-insert the column and repopulate it if you need to re-add it. Obviously this could be time consuming if your data is excessively large.
Depending on your application, just don't create the column in the first place. You don't say why you want to hide it, so if you just don't want it, don't add it.
Implement your control as a virtual control which gives your application control over what to display where. The burden of data display management falls to you to do manually but you have a great deal more flexibility. Inherit the class with wxLC_VIRTUAL style and implement OnGetItemText http://docs.wxwidgets.org/3.0/classwx_list_ctrl.html#a92370967f97215e6068326645ee76624
Edit:
To expand on the comment question, how to get the selected item index:
The wxListCtrl is a little weird when it comes to selected items. I'm sure it has to do with needing to support report, icon, etc. different views. When dealing with a multi-column report mode, you might find that you can only select items in the first column. If you are on Windows, it should automatically be set to "Full Row Select" but I don't know about other OSs.
Anyway, here is a utility method that returns the first selected item (note that you can support multi-selection if you want to).
//Get the item currently selected
int ListView::GetItemSelected() const
{
for(int i=0; i<GetItemCount(); ++i)
if (GetItemState(i, wxLIST_STATE_SELECTED) == wxLIST_STATE_SELECTED)
return i;
return -1;
}
If you want (and it makes sense), you can connect the list item selected event.
this->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxCommandEventHandler(ListView::selected_Changed), NULL, this);
and within that event handler, get the selected item and do what needs doing (depending entirely on your application).
You will note that I'm using a derived class here which just makes things a lot easier but you don't have to. You can connect to something like MyMainForm::sqlResults_selectedChanged or whatever.
There is more than one way to accomplish all this and you can also find some good suggestions and help here: https://wiki.wxwidgets.org/WxListCtrl

Eclipse Scout Neon table cell mouseover

I would like to know how to achieve mouseover on a cell, if a column is too short for full text.
So, if I have column with fix width, and text is too long, how to present whole text with mouseover in a cell.
You can dynamically add a mouse over tooltip on any cell by overriding the
execDecorateCell(Cell view, ITableRow row, IColumn<?> col) method in AbstractTable and setting your tooltip text like
#Override
protected void execDecorateCell(Cell view, ITableRow row, IColumn<?> col) {
super.execDecorateCell(view, row, col);
view.setTooltipText("Hi there: " + view.getText());
}
Unfortunately, this does not consider if your text length exceeds the length of your column/cell. It will set the tooltip text in any case! So far, I am not sure, whether (or how) it is possible to calculate (in pixels?), if the actual string length inside a cell exceeds ones column length. Maybe you could try something, that takes the actual string length into account (java.lang.String.length()) and only provide a tooltip if a certain length is given.
Let me know, if this is works for you!
Best regards,
Matthias
The tooltip for truncated text in a table cell is currently only shown if it is not possible to resize the column. This is done by purpose because the tooltip may be very annoying. The code responsible for this is in the file Table.js:
scout.Table.prototype._isTruncatedCellTooltipEnabled = function(column) {
return !this.headerVisible || column.fixedWidth;
};
If you don't like this behaviour, you could adjust the JavaScript code. There are mainly two ways for doing this:
Replace the original function
Extend the table and override the function
With the first approach you replace the actual function, so everytime a scout.Table gets created this function is used. With the second approach you need to make sure your new table is used. In order to do this you need to specify a mapping between the object type and the constructor which will be used whenever an object should be created using scout.create(objectType). This is normally done by convention, so if you write scout.create('Table') a new scout.Table will be created. Because you now want to create a custom table you need to add the mapping to scout.objectFactories.
For me, the first approach feels more like patching, whereas the second one is a cleaner solution. The advantage of the second solution is that the original object stays untouched and you could, at least theoretically, still create regular tables. That's why I suggest to use the second approach. But in the end it is probably a matter of taste.
In both ways, you need to create one or more JavaScript files, register them in yourproject-module.js and include this module in your index.html. The files could look like this:
Approach 1:
patches.js
scout.Table.prototype._isTruncatedCellTooltipEnabled = function(column) {
return true;
};
Approach 2
CustomTable.js
scout.CustomTable = function() {
scout.CustomTable.parent.call(this);
};
scout.inherits(scout.CustomTable, scout.Table);
/**
* #override
*/
scout.CustomTable.prototype._isTruncatedCellTooltipEnabled = function(column) {
return true;
};
objectFactories.js
scout.objectFactories = $.extend(scout.objectFactories, {
'Table': function() {
return new scout.CustomTable();
}
});
Remember: The scout JavaScript code is not api and may change anytime. You won't get compile errors if the function will be renamed as you are used to with java. So before adding a lot of custom JavaScript code to adjust the default behaviour you should consider opening a bug first so that it can be fixed in Scout. It could help others as well.

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

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.

How to access another field/combo in the rowedittemplate during creation of a grid row when selectionChanged or checkValue happens?

The situation is as follows :
I am creating a row in the grid. I have several properties among which are one combo called 'department' and one field called 'name'. The business rule is that all the 'names' in a 'department' must be unique. The grid does not load all the department-name combinations so I have to make a call to the back-end. I want to make this call when
selectionChanged on the 'department' combo happens or
when 'checkValue' of the validator options of the 'name' filed happens.
This way I check when either changes. The problem is that this happens during creation and there are no rows in the datasource and no accumulated rows in the transaction log.
How can I access the fields of the 'rowEditTemplate' during creation during these particular events in order to check my values? Is there any other/better way to achieve this?
The editors are not created until you do the first edit. You could use the editRowStarted event to attach your editors logic. They are obtainable using the editorForKey method.
editRowStarted: function (evt, ui) {
var comboEditor = ui.owner.editorForKey("ProductDescription");
}
I created a small fiddle that assigns a data source for the combo on editRowStarted. It should work as a starting point for what you are trying to achieve.
http://jsfiddle.net/hfen0qea/