Disable selection on first column of grid - grid

Is there a way to disable selection on the first column of a grid only. I have 2nd and 3rd column as 'checkcolumn', which fires selection for that row. That's why I cannot entirely use
disableSelection: true
on the grid, because this would disable the selection fire event on checkboxes. The first column is just a text, and I don't want selection of that row when the first column's row is clicked.
Any help?

The beforeitemmousedown event will probably work for you, add it as a listener where you declare your grid and return false when the event's target is the first cell in the row:
listeners: {
beforeitemmousedown: function(view, record, item, index, e, eOpts)
{
if(item.cells[0] == e.target.parentElement)
return false;
}
}

Related

tornadofx EventBus expand table row using tableview object

Background:
Suppose I have multiple fragments of a single table in a view, each with a rowExpander.
Expected Behaviour:
If in one table fragment I expand a row, other fragments same indexed row should get expanded. Same for collapse
My Progress:
Sample Fragment:
tableview(dataset) {
column("First Name", Person::firstNameProperty)
column("Last Name", Person::lastNameProperty)
rowExpander(true) {
selectedData.item?.apply {
fire(ExpandDataEvent(dataset.indexOf(this)))
}
column("Mobile Nos.", Person::mobileNumProperty)
column("Email Ids", Person::emailIdProperty)
}
bindSelected(selectedData)
subscribe<ExpandDataEvent> { event ->
selectionModel.select(event.index)
}
}
Event Class:
class ExpandDataEvent(val index: Int) : FXEvent()
What I understand from "subscribe" is that it gets called when an event is fired (currently I am firing the event whenever the user expands the row by either double-click/clicking the plus sign); and since the subscribe is placed inside tableview, it gets called for all the table fragments present (which is what I want). But in the subscribe method I am doing a selectionModel.select(event.index) which only selects the corresponding index row. I want to expand the row (preferably by using the selectionModel)
Question 2:
Is it possible to remove the plus sign column? For rowExpand, if I have set expandOnDoubleClick to true, I dont want the plus sign column in my tableview.
The rowExpander builder returns the actual ExpanderColumn which is basically a normal TableColumn. Save a reference to the expander so that you can operate on it later:
val expander = rowExpander(true) { ... }
Directly below, you can now hide the expander column:
expander.isVisible = false
Now it's easy to toggle the expanded state of a specific row from the event subscriber as well:
subscribe<ExpandDataEvent> { event ->
expander.toggleExpanded(event.index)
selectionModel.select(event.index)
}
You might want to double check that you don't toggle the expander for the tableview that fired the event, so consider including the event source in your event and discriminate on that in the subscriber.
I will investigate if we can add a visible boolean parameter to the rowExpander builder function so you don't need to call isVisible manually :)

Disabling a row in a DOJO / Gridx grid

I have a grid I created in Gridx which lists a bunch of users. Upon clicking a ROW in the grid (any part of that row), a dialog pops up and shows additional information about that user and actions that can be done for that user (disable user, ignore user, etc.) - when one of these options is selected from the pop up, I want to DISABLE that row. The logic for getting the row, etc. I can take care of, but I can't figure out how to make a grid row actually "appear" disabled and how to make that row no longer clickable.
Is there a simple way to do this? If you aren't familiar with gridx, solutions that apply to EnhancedGrids or other Dojo grids are also appreciated.
Alright now that I have a little more information here is a solution:
Keep a list of all the rows you have disabled so far either inside the Grid widget or in its parent code. Then on the onRowClick listener I would write code like this:
on(grid, "onRowClick", function(e) {
if(disabledRows[rowIndex]) {
return;
}
// Do whatever pop up stuff you want and after
// a user selects the value, you can "disable"
// your row afterwards by adding it to the disabled
// list so that it can no longer be clicked on.
var rowIndex = e.rowIndex;
disabledRows[rowIndex] = true;
// This is just some random class I made up but
// you can use css to stylize the row however you want
var rowNode = e.rowNode;
domClass.add(rowNode, "disabled");
});
Note that domClass is what I named "dojo/dom-class". Hope this helps!
This is perhaps not exactly what you are seaching for:
If you want to hide one or more rows by your own filterfunction you could just add to these rows in the DOM your own class for nodisplay. Here I show you a function for display only those rows which have in a choiceable field/column a value inside your filterlist.
function hideRowFilter(gridId, fieldName, filterList)
{
var store = gridId.store;
var rowId;
store.query(function(object){
rowId = gridId.row(object.id,true).node();
if (filterList.indexOf(object[fieldName]) == -1)
domClass.add(rowId, "noDisplay"); // anzeigen
else
domClass.remove(rowId, "noDisplay"); // verstecken
});
}
CSS:
.noDisplay { display: none; }
So I can for example display only the entries with a myState of 3 or 4 with this call:
hideRowFilter(gridId, 'myState', [3, 4]);
Note that domClass is what I named "dojo/dom-class"

Extjs4 how to disable itemClick event of grid's certain column

I am working in extjs4. I have grid panel view as=
i want to show image in floating window whenever user clicks on grid row.So i have written function namely showImage() and calling it as=
me.mon(me, {'itemclick' : me.showImageViewer
}, me);
But i dont want to call this function when user clicks on FileName column of grid. So how to restrict calling showImage function when user clicks on grid column 'FileName'
You can listen to the column click function. Define common listener for columns you need. In arguments you should recieve grid, cell element, row index, column index, event data and record(in such order). So if you'll move, rename headers or do whatever you want with column with such listener it wouldn't change click listener.
i want to show image in floating window whenever user clicks on grid row.
Do you mean you'll show a popup containing the bigger image if image on row is clicked? if yes, on your showImageViewer function, you have to check the attributes of the cell if it's an image or you can check its dataIndex.
You can also listen to cellClick instead of itemClick. With that, you can check the cellIndex of the cell being clicked. In your case, if cellIndex is equal to 2 (index of your FileName column, don't call showImageViewer.
cellClick : function(view, cell, cellIndex, record, row, rowIndex, e) {
}
You can use a css selector to differentiate between elements inside the row, using a code like the following
listeners: {
itemclick: {
fn: function (view, record, item, index, e, eOpts) {
var photo = e.getTarget('.photo');
if(photo) {
alert(record.get('photo'));
}
}
}
You can try a working sample here. Hope it helps to solve your problem

How do I hide a row in BIRT?

I have a data table with 2 detail rows. In certain cases I want to show the first detail row and in some cases I want to show the 2nd. Something like:
if (row["field"] == "N") {
hideRow1();
}
else {
hideRow2();
}
In the layout tab in BIRT Report Designer, select the first detail row (so that it is higlighted).
In the Properties tab of the Property editor for the row, select the Visibility section:
Check the Hide Element checkbox;
Click the fx button next to the Expression, and enter a formula like: row["field"] == 'N'.
Repeat the process for the second detail row with a formula like: row["field"] != 'N'.

show different item on selectionchange on a grid

i have a grid and a form, i need to show different items on the form each time we select a row on that grid
i ve been looking on how to do this, and found
Ext.getCmp('myform').hide() // or .show()
and
listeners: { selectionchange: function () {...}
now i dont know which row is selected so i can specify which item to show
thanks
You get the selected rows as second parameter in the selectionchange event handler:
listeners: {
selectionchange: function (view, selections, options) {
console.log(view, selections, options);
}
}
So the first selected row is the first element in the selections array:
record = selections[0]
This is described in the Ext JS 4 API documentation for the selectionchange event.
Try to following code in your grid.
listeners:{
itemclick:function(view, record, item, index, e ) {
var v = record.get('firstName');
....
....
}
}
firstName will be your dataindex of colums in your grid.
You can get value of any field like this.

Resources