Created
May 24, 2019 07:53
-
-
Save MashmatrixSupport/d0d81eef17350e1208b27d49a2b48339 to your computer and use it in GitHub Desktop.
JavascriptApiDemo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page> | |
<apex:form> | |
<!-- Please replace the following bookId/sheetId attribute values to the values of from book/sheet setting dialog --> | |
<apex:pageBlock title="Accounts"> | |
<msmxSheet:SheetView id="comp-01" | |
bookId="a002800001O6vOpAAJ" | |
sheetId="s1" | |
width="100%" | |
height="300px" | |
/> | |
</apex:pageBlock> | |
<!-- You need to create a filter for `Account ID` field, with the value of "${params.AccountId}" --> | |
<apex:pageBlock title="Opportunities"> | |
<msmxSheet:SheetView id="comp-02" | |
bookId="a002800001O6vOpAAJ" | |
sheetId="s2" | |
width="100%" | |
height="300px" | |
/> | |
</apex:pageBlock> | |
</apex:form> | |
<script> | |
// When records are loaded in the sheet or selection of records are changed, update the `AccountId` parameter from passed records' IDs. | |
function handleRecords(params) { | |
console.log('params =>', params); | |
var accountIds = params.records.map(function(record){ return record.$id; }); | |
MsmxSheet.updateApplicationParameter({ AccountId: accountIds }); | |
} | |
// When a cell is focused, get ID of the record and update the `AccountId` parameter | |
function handleFocus(params) { | |
console.log('onFocusCell =>', params); | |
var accountIds = [params.cell.recordId]; | |
MsmxSheet.updateApplicationParameter({ AccountId: accountIds }); | |
} | |
// Subscribing "Accounts" sheet | |
// When completed the record loading | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'loadComplete', handleRecords); | |
// When selection changed by checking record selection checkbox | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'selectRecords', handleRecords); | |
// When a cell is focused | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'focusCell', handleFocus); | |
</script> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To create this demo, you need to create a book with sheets of "Account" and "Opportunity" object.
Account
object as a data source. New book will be created with one sheet tab named "Account".Opportunity
object. A sheet named "Opportunity" will appear on the next of the "Account" sheet.https://www.youtube.com/watch?v=xxMh12u8ATY