tabulator - function rowselectionchange - javascript

does the table.rowSelectionChange function allow me to locate the ids of the "DESELECTED" rows instead of the rows that remain selected?
when I deselect some lines in console.log I read the lines left selected instead of the ones I deselected

Related

How to get specific selection of checkbox from a popup datatable in Webix?

I have a popup data table in each row of a maintable with some checkboxes in it.
I am selecting/checking items randomly by clicking the checkbox buttons for each row and printing the values checked with the help of Print button.
I am observing that only the last selection of checkbox buttons are overwriting all the earlier selections.
How can I get the appropriate selection of checkbox buttons corresponding to each row?
Snippet: https://snippet.webix.com/11irkt7o
Thanks.
You code uses a single instance of popup table for each rows, so as result whey you are calling $$pt.eachRow you are itterating other the last active value, all previous values are lost.
The better solution will be to use click handler of close button, to get all checked rows and store that data in the master row
{view:"button", label:"Close", click:function(){
ids = collectCheckedRows($$('p_table'));
$$('mytable').updateItem(selectedRow, { checked : ids })
this.getTopParentView().hide()
}}
Now, to print all values you can use
$$('mytable').eachRow(function(id){
console.log(id, this.getItem(id).checked);
});

Clear previous selection only if checkbox is not clicked in jQgrid?

I have a grid setup with multiselect: true because I need to be able to delete more than one row at the same time. On the onSelectRow event I am loading some data based on the ID and displaying it to the end user. So far so good.
This is the example where everything works fine, the data for ID=219109 is being displayed:
Now look at the following example:
In the example above the first row still highlighted and then I clicked a second one. Because of multiselect is enabled I was able to select both at the same time. The onSelectRow event still working properly which means is loading the data for the ID=282006 but visually it could be confusing for the end user.
What I want to do is to reset the previous selected rows and just highlight the last one I have clicked.
For example using the same images:
Load a fresh grid with no rows selected
Click on ID=219109: highlight and select this row
Click on ID=282006: clear the grid and highlight this row
However this should only happen when I click in any other place than the checkbox.
In the image above if I click on any column rather than the first one (the one having the checkbox) I should be able to clear the grid selection and choose the last one but if I click on the checkbox it does not matter because is the only way to delete more than one at the time.
I have tried the following:
onSelectRow: function () {
var rowid = $(this).jqGrid('getGridParam', 'selrow');
$(this).jqGrid("resetSelection");
$(this).jqGrid("setSelection", rowid);
}
But it's not working since the behavior is not consistent. You can check the demo here.
Any ideas in how to achieve this?
It seems to me that you need just add the option
multiboxonly: true
and remove your current onSelectRow code. See https://jsfiddle.net/OlegKi/949pLpfv/3/. If the user clicks multiple times on checkbox the rows will be selected. The click on another part of the row will deselect all previously selected rows and select only the clicked row.

jqgrid get rowData values without selecting multi-select checkbox

I have a jgrid with multiple rows and 5 columns without check-boxes. In 5th column it has screen permissions. I had given the sample of jqgrid below.
So when i am changing screen permissions either by clicking on the close mark or clicking on plus mark i am deleting existing or adding other available permissions to the screen.
Here i am doing same operation for multiple rows in grid. When i am clicking on the SAVE button outside of the grid i need to get the edited row values and need to send back to controller.
I tried this functionality with the selarrow function of jqgrid. but i am not getting these edited row values without selecting the checkbox of the row.
Could any one help me how to get this edited row values without selecting the checkboxes of the row.
You can use the below code:
var lastSel;
jQuery("#gridid").jqGrid({
...
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery(this).restoreRow(lastSel);
lastSel=id;
}
jQuery(this).editRow(id, true);
},
...
});
onSelectRow :Raised immediately after row was clicked.
rowid: is the id of the row,
status: is the status of the selection,
e: is the event object. Can be used when multiselect is set to true. true if the row is selected, false if the row is deselected.
You Can refer this as well:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:events

How to find text node in javascript

I have a table with two columns. And i can't change it. In the left column there are checkboxes, their id's and names are made from this pattern - id="selected[0]" and so on.
In the right column there are only anchor tags with text inside.
I need to check if checkbox next to specific cell with specific text is checked or not.
You can use jquery to find a cell containing a specific text.
e.g. if text is 'hello world' than you can do a search for nodes and go to next element to it like this
var checkBox = $("td:contains('hello world')").next(); // to go to next, use prev() to go to previous element to the cell
var isChecked = checkBox.is(":checked"); // to check if checkbox is checked

Primefaces: Handling multiple DataTable Rows, Columns, cell

I wanted to know if it is possible to select an entire row or column in the DataTable or DataGrid when making click with the mouse. I've tried to handle it in the ManagedBean apart and integrate a javascript to capture data and manage the columns and rows but without any results.
Then, we need this actions on the table:
Column selection (It should get a string with the values of each cell for the entire column) RED
Cell selection (It should get the value of the cell and also, the number of the column and the number of the row where this cell is located) BLUE
Row selection (It should get a string with the values of each cell for the entire row) GREEN

Categories