Last active
July 23, 2018 03:47
-
-
Save MashmatrixSupport/f9057c8f7b538ab42df31bd67006bfe9 to your computer and use it in GitHub Desktop.
上下シートの連動(取引先/商談)
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> | |
<!-- bookId/sheetIdに指定するブックID/シートIDはブックおよびシートの設定画面から取得したものに置き換える --> | |
<apex:pageBlock title="取引先"> | |
<msmxSheet:SheetView id="comp-01" | |
bookId="a002800001O6vOpAAJ" | |
sheetId="s1" | |
width="100%" | |
height="300px" | |
/> | |
</apex:pageBlock> | |
<!-- あらかじめ商談シートには取引先ID項目の列に対して "${params.AccountId}" を値として参照するフィルタを適用しておく --> | |
<apex:pageBlock title="商談"> | |
<msmxSheet:SheetView id="comp-02" | |
bookId="a002800001O6vOpAAJ" | |
sheetId="s2" | |
width="100%" | |
height="300px" | |
/> | |
</apex:pageBlock> | |
</apex:form> | |
<script> | |
// レコードがロードされた/チェックボックスで選択されたとき、選択されたレコードのIDでAccountIdパラメータを更新 | |
function handleRecords(params) { | |
console.log('params =>', params); | |
var accountIds = params.records.map(function(record){ return record.$id; }); | |
MsmxSheet.updateApplicationParameter({ AccountId: accountIds }); | |
} | |
// セルがフォーカスされたとき、該当セルの行のレコードIDでAccountIdパラメータを更新 | |
function handleFocus(params) { | |
console.log('onFocusCell =>', params); | |
var accountIds = [params.cell.recordId]; | |
MsmxSheet.updateApplicationParameter({ AccountId: accountIds }); | |
} | |
// 取引先シートのイベントのSubscribe | |
// レコードのロードが完了したとき | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'loadComplete', handleRecords); | |
// レコード選択チェックボックスでレコードを選択したとき | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'selectRecords', handleRecords); | |
// セルがフォーカスされたとき | |
MsmxSheet.subscribeComponentEvent('comp-01', 'a002800001O6vOpAAJ/s1', 'focusCell', handleFocus); | |
</script> | |
</apex:page> |
Author
MashmatrixSupport
commented
Jul 19, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment