Slickgrid 2.1 - Apply and Remove Formatters On The Fly (i.e., Depending on Runtime Conditions) - slickgrid

I'm using slickgrid 2.1 and successfully using a formatter for one of my columns in order to display a button that, when clicked, deletes the corresponding row from the grid.
My requirements and question: I need to only display this button in the row the user single-clicks on. When the user clicks one row, then another, the button from the first selected row needs to be hidden and the button on the second selected row needs to be displayed. How can I programmatically do this?
Many thanks.

Related

Kendo grid. Event when selection is become empty

I need some event when my Kendo grid lose selection (no row selected).
https://dojo.telerik.com/#nick_kingston/IjIYOduw
Select one or more rows.
Filter by some field that so no selected rows show.
Expecting event appearance because now no row selected.
How to implement item 3?
There is no event like lostSelection. The change-event triggers if the user changes the selection only.
Once the filter was executed, the dataBound-event is triggered (as you can see on the demo page https://demos.telerik.com/kendo-ui/grid/events). There you could check for the list of selected items with the method select (https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/select)

Kendo grid. Update only current row in popup, even if other was changed

For example I have many many rows which contains 2 columns: checkbox and input, and popup window with editing. In DataSource I have 'Update' event, which call method for updating from controller.
Question: Is it possible to make such situation: User check checkbox on first row -> open popup for second row -> submit changes. Only second row should be updated, not all.
I want pass to server item only from current row. Actual result is that all changed rows passed to method 'Update'
This situation appears because in my application combined "incell" and "popup" editing for Kendo Grid.

slick grid - unheck all rows for paging, sorting and search events

I am using SlickGrid with the checkbox selector plugin and the pagination plugin. I want to only allow the user to select rows for the current page. I noticed that slickgrid remembers values that the user selects on a previous page. Only when a user selects a row on the current page does it uncheck the rows on a previous page. Is it possible to uncheck all rows on a page change event.
Similarly if the user does a search I want to unselect all rows.
Same with sorting, unselect all rows for the grid when the user does a sort.
Is it possible to do this?
The checkbox selector plugin was not designed for pager. Whenever you set checkbox as selected using the plugin, it remembers the row indices _selectedRowsLookup of the grid and re-apply the formatting when the grid invalidates. Thus, it will be the same rows check/unchecked on each page.
To achieve what you want, you have to customize the plugin where you need to:
Add a flag/field isSelected to your dataset that store if a record is selected
Set the formatter to check the dataContext.isSelected instead of using the _selectedRowsLookup
Change the handleSelectedRowsChanged to modify the field isSelected to true or false with the correct reference on the current page.
To select the rows of current page, change handleHeaderClick to only modify the rows displayed using the current pagingInfo
To clear the selection, reset the isSelected field to false and invalidate the grid rows.

Jqgrid - How to create a custom add-button that you can supply of parameters

When you create a jqgrid there is a default button on the bottom of the grid that allows you to create new records.
However, when you open the modal, all input fields are empty.
In my situation I need this button, but I also need the exact same thing but with the possibilty of adding a few parameters so some of the fields are already filled in. The parameters would come from the selected row at that moment.
Like when I click a row where the date is set to 01/01/2099 i need the add-modal to open with the date already set to that date.
You can use beforeShowForm or afterShowForm to make any changes in the Add Form during opening. For example you can read the values from currently selected row and fill some fields of the form with new values. To be open Add form on click or double-click on the row you need just call editGridRow inside of onSelectRow/ondblClickRow callback.

Is it Possible to show and hide some Slickgrid Columns on button click

I need to show/hide some of the slickgrid columns on the click of a button. Is it possible?
For example , I have a slickgrid having 3 columns. On click of a button I want to show three more columns i.e 4,5,6. On clicking the button again these columns should hide and another div should take its place. So basically toggle 3 of the 6 slickgrid columns.
Thanks
SlickGrid doesn't have a concept of showing or hiding columns. It shows whatever columns you specify in the constructor or in a later call to grid.setColumns(). If you want to hide a column, just remove it from the columns array you call grid.setColumns() again.
You can keep the original columns array with all the columns in a separate variable.

Resources