Slickgrid checkboxselectcolumn click checkbox dynamically - checkbox

I am using the checkboxselectcolumn plugin for Slickgrid, and I want new rows to be selected automatically.
I tried getting the current selected rows and adding the new index, and when i get selected rows, my row is in the list, but the checkbox is not actually selected and the row highlighted. I can't seem to find the code to "click" the checkbox.
_grid.dataView.addItem(item);
var selectedItems = _grid.grid.getSelectedRows();
console.log(selectedItems); //Rows selected or empty
selectedItems.push(_grid.grid.getDataLength()+1);
_grid.grid.setSelectedRows(selectedItems);
selectedItems = _grid.grid.getSelectedRows();
console.log(selectedItems); //New rows are all in this list, but checkbox is not selected

I used jQuery to "click" the checkbox (Just setting it to checked wasn't enough)
var nextIndex = _grid.grid.getDataLength();
jQuery('#MyGrid div[row='+nextIndex+'] [type=checkbox]').click();

Related

Material ui Datagrid get value on unchecking checkbox

I am using Material ui datagrid. I want to get the value on uncheck of checkbox also.
I have an API which update the Datagrid, on selection I get the selected row data which then on button click I update the value into another array of object, Now when I close the datagrid and open again I want the data to be shown in table comparing if already present in array of object mark it as selected in checkbox, Now when i deselect the checkbox i need the ID and the row data which was removed so I can update the array again, but here on deselect the checkbox it shows empty, so how I can get the removed one so I can update my array
https://codesandbox.io/s/66424752get-row-item-on-checkbox-selection-in-react-material-ui-data-grid-wp4vl?file=/demo.tsx

ExtJS 6.5 View, how to unselect last one selected

I've got an Ext.view.View that has a list of templates rendered. When I select a row on the view, I want the previous one selected to be unselected. Currently, I have an onchange event that deselects everything (see below), but that causes problems when I have items filtered.
How can I DeSelect just the currently filtered rows. below is my unselect everything code.
Ext.Array.each(this.query('dataview'), function (v) {
v !== sm.view && v.getSelectionModel().deselectAll();
});
Want I'm wanting is to just deselect the rows that are filtered in the associated store. The problem with the above code is that when it runs, the filter gets removed and all the rows in the view show back up again.

How to select a checkbox in a gridx grid using row id?

I want the checkbox to be checked when I right click on the row in the grid. My application supports only javascript. It does not support jquery. So please send in your answers in javascript.
I used the following code to activate the right click event and get the ID value of the row that I have right clicked on. Please help me to check the checkbox of the corresponding row.
this.gridConnections.push(aspect.after(this.grid, "onRowContextMenu", lang.hitch(this, function(evt) {
var rowID = evt.rowId;
console.log("right click");
event.stop(evt);
}), true));
once you have the row object, you can also get the checkbox on that row like
this.yourcheckbox or dijit.byId("yourcheckbox"). Then use
this.yourcheckbox.set("checked",true) or
dijit.byId("yourcheckbox").set("checked",true);

Make a new row editable in ui grid

I am using ui-grid. The use-case is such that on clicking a button, a new row is added. I want to make this newly added row editable. i.e. as soon as the row is added, the edit mode is on for at-least the first cell in the row. Any suggestions on how to do it ?
Tried so far:
var newobj = {"id": "","name":"" };
$scope.gridOptions1.data.unshift(newobj);
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ROW); //set focus to the new row
$scope.gridApi.selection.selectRow($scope.gridOptions1.data[0]);
here's a plunker for the same
http://plnkr.co/edit/6zyZ5q?p=preview

EXTJS 4 Grid selection model row

I have a grid and when I click on a button in the toolbar of the panel I want to check if a row in the grid is selected.
If true I need de value of one cell of that row, so I can put it behind a url.
But I have no idea how I can use the selection model to get the cell value of a selected row in EXT JS 4.
Perhaps try something like:
grid.getSelectionModel().getSelection()
This will return an array of all selected records withing the grid.
Then, you can iterate over the selection, find your row and call row.get('PropName') to get the value.
Hope this helps.
You're approaching the issue backwards though. You want to register for the 'selectionchange' event from the grid.
thisController.control ({'#mygrid':
{
selectionchange:onSelectionChange}
});
function:onSelectionChange(model, selected, eOpts )
{
//do work here
}
So basically you want to create an event driven model.

Resources