User Manual

08.14.2024

MANUAL

FAQ: I want to transfer the value of a parent table item to a child table item

## Answer Use "[Script](/en/manual/table-management-script)". **This can be achieved with the "[Lookup](/en/manual/table-management-lookup)" function in .NET Framework version 0.50.251 and later, and .NET Core version 1.1.27 and later.** --- ## Overview In tables that are parent-child relationships using the "[Link](/en/manual/table-management-choices-text-link)" function, the value of the item entered in the parent table is transferred to the item in the child table. As an example, when [Table A (parent)] [Table B (child)], the sample code for setting the value of "Classification A" in Table A to "Classification B" in Table B as the link item is shown below. (In this example, a script is set in Table B). In Pleasanter, if you use [$p.apiGet](/en/manual/script-api-get), you can obtain values ​​by ajax POST request just by specifying the record ID. *If you are using version 1.3.12.0 or earlier, some of the description will be different. Please check the comments in the sample code. ## Operation Method 1. Select the table for which you want to set the script and display the record list screen 1. From the navigation menu, select [Management]-[Table Management] to display the table management screen 1. Select the [Script] tab and press the "Create New" button to set the script 1. After writing the "[Title](/en/manual/tenant-logo)" and "[Script](/en/manual/table-management-script)", check "Create New" and "Edit" in "Output Destination" *If you have set [Edit in Dialog], you must also check "List" ## Sample Code ##### JavaScript ``` //Event when loading the edit screen $p.events.on_editor_load = function () { getParentData(); } //Event called each time the value of "Classification A" in table B is changed $(document).on('change', '#' + $p.getControl('ClassA')[0].id, function () { getParentData(); }); getParentData = function() { //Get the value of the specified record in table A only if a value is set in table B's "Classification A" if ($p.getControl('ClassA').val()) { $p.apiGet({ //Specify the value (record ID) of table B's "Classification A" 'id': $p.getControl('ClassA').val(), 'done': function (data) { //Set the value of "Classification A" obtained from table A to table B's "Classification B" //*If you are using version 1.3.12.0 or earlier, remove the // at the beginning of the following comment line and delete the line that follows. //$p.set($p.getControl('ClassB'), data.Response.Data[0].ClassA); $p.set($p.getControl('ClassB'), data.Response.Data[0].ClassHash.ClassA); }, 'fail': function (data) { console.log(data); } }); } else { //If no value is set in "Classification A" of table B, set an empty string to "Classification B" of table B $p.set($p.getControl('ClassB'), ''); } } ``` ## Related Information <div id="ManualList"><ul><li><a href="/en/manual/table-management-choices-text-link">Manage Table: Editor: Column Advanced Settings: Option List: Link</a><span>10.11.2024 up</span></li> <li><a href="/en/manual/table-management-lookup">Table Management: Editor: Item Detail Settings: Choice List: Lookup</a><span>08.13.2024 up</span></li></ul></article> <ul><li><a href="/en/manual/table-management-script">Table Management: Script</a><span>08.13.2024 up</span></li></ul></article> <ul><li><a href="/en/manual/tenant-logo">Tenant Management Function: Logo, Title, Logo Image</a><span>10.08.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.