Specify what column triggers data-toggle event - footable

I want to be able to specify what column triggers the data-toggle event so I can have other columns respond to a different event with out toggling the data.
Here's a plunk that will show what I'm seeing: http://plnkr.co/edit/wqyuuqNfb6qxXBWyHoRo
All columns in a row except the first and last will show a modal dialog when clicked. When the screen is shrunk and the data is collapsed, the toggle icon is displayed on the first column. When you click this icon, the data is toggled as expected. The problem I have is when you click the first name, the data is toggled and then the modal is shown. Is there a way to restrict the toggle event to just the column that is specified?

I found an solution. Just add a trigger to collapse the expanded data as below.
$("table").on("click","td:not(.footable-first-column)",function(e){
var row=$( this ).parent();
$(row).trigger('footable_toggle_row');
$(".modal.fade").modal("show");
return false;
});
Please find the solution in this plunk: http://plnkr.co/edit/QRQyhvvSOmz5oDlR0Cph?p=preview

There was an update to https://github.com/bradvin/FooTable/issues/189#issuecomment-44100073.
I was using the answer by #Duli, but I think this works better.(I will keep his answer as the one I accepted)
When I initialize the table I add an option to change the toggleSelector and that causes the row to only toggle when the icon is selected and not the row.
$('.footable').footable({
toggleSelector: " > tbody > tr > td > span.footable-toggle"
});

Related

Select single row with checkbox in sap.ui.table

noobie_sapui5_developer
I am trying select single row of sap.ui.table with checkbox.
There are 2 modes for this table
Multi
Single
In multi selection mode there are checkboxes for each row and multiple rows can be selected - but I want only a single row to be selected
In single selection mode, it allows only a row to be selected - but there are no check boxes.
How to achieve a table with checkboxes with only one selectable row?
It is possible with sap.m.table, but my requirement is to make it work with sap.ui.table.
Why I wouldn't recommend doing this:
Checkboxes (selectionMode="MultiToggle") are usually used to signal the user that he's able to select no, one or more options, while radio buttons (selectionMode="Single") tell the user that he's only able to choose one option.
See: material.io, nngroup, uxplanet-radio, uxplanet-checkbox
In your case, I'd recommend using the selectionMode="Single" and either set the selectionBehavior attribute to Row, RowOnly or RowSelector (SelectionBehaviour).
As #jasbir pointed out, you could use the rowSelectionChange event in order to invoke a function that grabs the index (getSelectedIndex) of the row that was just selected. You can then call the setSelectedIndex function on the sap.ui.table.Table and pass it the grabbed index. This will remove previously selected rows and set the currently selected row as selected.
<Table id="yourTableId"
selectionMode="MultiToggle"
rowSelectionChange="onSelectionChange">
</Table>
And in the controller.
onSelectionChange: function(oEvent) {
var oYourTable = this.getView().byId("yourTableId"),
iSelectedIndex = oEvent.getSource().getSelectedIndex();
oYourTable.setSelectedIndex(iSelectedIndex);
}
Note: Since the setSelectedIndex function triggers a rowSelectionChange the above function gets triggered twice (another indicator that this solution isn't intended behaviour).
Check the SAP Fiori Guidelines for the sap.ui.table.Table for further information.
You can use rowSelectionChange event whenever a selection is changed you can unselect other rows and keep the selected one.
Hope this helps

Ag-Grid expand row

Im using Ag-grid to control my table, but i want in my group that stores a list of rows instead of having to make the row group expand in 2 clicks, i want to be on 1 click.
If i click on the icon arrow it works, but if i click on the title row it only opens on 2 clicks.
I already tried to find in the documentation any information about it, but cant find nothing.
Here is a example from the documentation.
https://ag-grid.com/javascript-grid-tree/index.php
example image:
We are now recommended not to use the onGroupExpandedOrCollapsed, so this should now be...
This will also update the icons and animate the rows, which onGroupExpandedOrCollapsed won't.
onRowClicked(params) {
params.node.setExpanded(!params.node.expanded);
}
This will toggle the expansion, use params.node.setExpanded(true) if you want the rows to just stay open.
You can listen to events on either a row or cell clicked, and expand nodes accordingly.
For example to expand a row based on a click you could do the following:
onRowClicked: (params) => {
// update the node to be expanded
params.node.expanded = true;
// tell the grid to redraw based on state of nodes expanded state
gridOptions.api.onGroupExpandedOrCollapsed(params.rowIndex)
}
This should be in the documentation - I'll update it to reflect this information.
In the column definition, you can use the onCellClicked(params) function to tell it to do something when the cell is clicked. I tried looking for an expand function, but I could only find expandAll() which I don't think you will want. So what I would do is just use jquery or simple DOM selection to click on the expand icon inside of that cell.
this one works
onRowClicked(params) {
params.context.setExpand.onExpandClicked(params.rowIndex, params.node.rowHeight);
}

How to set css class to a row which has focus in Dojo datagrid

I am using DOJO datagrid version 1.10 What I want is on tab indexing the row in the grid should get highlighted so that user will be able to know on which row the focus is. But I am not getting the row focus.
You could listen on the dojox.grid.DataGrid::onCellFocus event. The event arguments are the focused cell-Object itself and the corresponding rowIndex.
function onCellFocus(cell, rowIndex) {
// first clear selection
grid.selection.clear();
// select the focused row
grid.selection.setSelected(rowIndex, true);
// invoke manually the render method
grid.render();
}
I've created a working fiddle for you, which can be found here.

Select jQuery UI Button by Label or $.Data

My buttons are input type=button, id field set, and no text in between the tags since it appears to the right of my buttons rather than inside. (sorry, won't let me publish the html for some reason).
I .button() them and set their label. All works as expected, but I can't select them by :contains().
How do you select jQuery UI buttons by their labels?
Thanks in advance!
Edit
I don't select by id because the text of the button changes based upon a variable in my db. Is there a way to select by .data?
You should create a button and look how jQuery creates it. When you look at the example in the documentation you see that .button() creates a span element in the button element that contains the label. So you can query on this inner span element which has a class of ui-button-text.
But I think that you should overthink your code and rework it so that you can select on the ID since they are made to identify things.
Edit: Then go for the first advice
var buttons = $('button').filter(function (index) {
$('.ui-button-text:contains("' + your_string + '")', this).length > 0
});

How to add a custom selection Handler to a celltable

I want to add a special selection model to the celltable. Basically the function i want to have is to select a row on the table which is located on left side, a corresponding form will pop up on the right side.
I know so many people will use the singleSelectionModel with SelectionChangeHandler.
But there is problem with this method.
For example, if I select row 1 on the table. the form pop up. I close the form by clicking the close-button. Later then, I select the row 1 again, the event is not fired, because it is SelectionChangeHandler. I have to select other row before doing this. This is no good.
So I think there are a few ways to do this:
Make the row deselected right after I select the row.
Use click handler to fire the event ( to pop up the form)
Use other selection model with other selection handler to do this. (I have no ideas about this though)
So my questions are,
Does anyone know what kind of other selection handler I can use for this.
If I use the click handler on celltable, will there be any problem?
I just want to learn more about this. So any ideas will be welcome.
Thanks a lot.
Best Regards.
Use NoSelectionModel. It won't update the table view after the row is selected. That is, even if the same row is selected, the change event is fired.
//Here 'Contact' is the datatype of the record
final NoSelectionModel<Contact> selModel = new NoSelectionModel<Contact>();
selModel.addSelectionChangeHandler(new Handler() {
#Override
public void onSelectionChange(SelectionChangeEvent event) {
Contact clickedObject = selModel.getLastSelectedObject();
GWT.log("Selected " + clickedObject.name);
}
});
table.setSelectionModel(selModel);
I have using cell table in my each project. The better way to just deselect row manually as u mention. and make change css such as selected cell table's row look not changed after selection.