OnCellChange Event capture in salesforce #1004
-
I am using slickgrid-universal in salesforce lwc. Followed the wiki and installed the grid and was able to load data and use bunch of features (was very easy, thanks ghiscoding!). I was trying different editors and trying to capture oncellchange even to save the update to salesforce. But the arguments to this handler function does not seem to work for me. args.item is undefined. Can someone please help? // HTML
//
//
// <div class="grid-container"> <div class="grid1"
// oncellchange={handleOnCellChange}>
// </div>
//</div>
//LWC
export class GridExample {
sgb;
async connectedCallback() {
//Loads all resources
const dataset = this.initializeGrid();
const gridContainerElm = document.querySelector<HTMLDivElement>(`.grid1`);
this.sgb = new Slicker.GridBundle(gridContainerElm, this.columnDefinitions, this.gridOptions, dataset);
}
handleOnCellChange(e, args) {
console.log("item is changed" ) //this prints
this.updatedObject = args.item; //this is shown as undefined
this.sgb.resizerService.resizeGrid(10);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Yeah some part of the docs came from Angular-Slickgrid and with Angular we have access to the event directly in the View (html) so we can do something like this So I updated 1 of the Wikis with the correct info, see Grid & DataView Events handleOnCellChanged(event) {
const args = event?.detail?.args;
const eventData = event?.detail?.eventData;
this.updatedObject = args.item;
this.sgb.resizerService.resizeGrid(10);
} all of Slickgrid-Universal are actually using this same approach, you just have to look at any examples to see the code, Example 12 has a few events hooked up. If you find more Wikis that could be updated with this info, feel free to submit a PR |
Beta Was this translation helpful? Give feedback.
-
Also please note that I haven't had a chance to update the zip file for the latest major v3.0.0 which was a breaking change version that removed jQuery. Basically as it is today, the zip points to v2.x and still requires jQuery, I'll try to update it to the v3.x branch in the coming days but you might have to follow the Migration to 3.0 |
Beta Was this translation helpful? Give feedback.
Yeah some part of the docs came from Angular-Slickgrid and with Angular we have access to the event directly in the View (html) so we can do something like this
(onCellChange)="onCellChanged($event.detail.eventData, $event.detail.args)"
(notice the 2 arguments) but we can't this in Salesforce because it doesn't allow any arguments in the View (html) which sucks but we have to live with Salesforce restructions. So how do we get theargs
then? You can find theargs
inside the event itself (which equals to what we can do in Angular but it comes from the event in the JS code instead of HTML).So I updated 1 of the Wikis with the correct info, see Grid & DataView Events