├── LICENSE ├── README.md ├── images ├── appbuilderconfig.PNG ├── datatableedit.PNG └── datatableview.PNG └── src ├── aura ├── DataTableApp │ ├── DataTableApp.app │ ├── DataTableApp.app-meta.xml │ ├── DataTableApp.auradoc │ ├── DataTableAppController.js │ └── DataTableAppHelper.js ├── DataTableV2 │ ├── DataTableV2.auradoc │ ├── DataTableV2.cmp │ ├── DataTableV2.cmp-meta.xml │ ├── DataTableV2.design │ ├── DataTableV2.svg │ ├── DataTableV2Controller.js │ └── DataTableV2Helper.js ├── DatatableLntgOut │ ├── DatatableLntgOut.app │ └── DatatableLntgOut.app-meta.xml ├── MyOutputClickEvt │ ├── MyOutputClickEvt.evt │ └── MyOutputClickEvt.evt-meta.xml ├── MyOutputField │ ├── MyOutputField.auradoc │ ├── MyOutputField.cmp │ ├── MyOutputField.cmp-meta.xml │ ├── MyOutputField.css │ ├── MyOutputFieldController.js │ └── MyOutputFieldHelper.js ├── Pagination │ ├── Pagination.cmp │ ├── Pagination.cmp-meta.xml │ ├── Pagination.css │ ├── Pagination.design │ ├── PaginationController.js │ ├── PaginationHelper.js │ └── PaginationRenderer.js ├── PaginationEvent │ ├── PaginationEvent.evt │ └── PaginationEvent.evt-meta.xml ├── Spinner │ ├── Spinner.cmp │ ├── Spinner.cmp-meta.xml │ └── Spinner.css ├── Toast │ ├── Toast.cmp │ ├── Toast.cmp-meta.xml │ ├── ToastController.js │ └── ToastRenderer.js ├── inputField │ ├── inputField.cmp │ ├── inputField.cmp-meta.xml │ └── inputField.css ├── outputField │ ├── outputField.cmp │ └── outputField.cmp-meta.xml └── svg │ ├── svg.cmp │ ├── svg.cmp-meta.xml │ ├── svg.css │ ├── svgController.js │ ├── svgHelper.js │ └── svgRenderer.js ├── classes ├── DataTableController.cls ├── DataTableController.cls-meta.xml ├── DataTableController_Test.cls └── DataTableController_Test.cls-meta.xml ├── package.xml ├── pages ├── Datatable.page └── Datatable.page-meta.xml └── staticresources ├── Datatable_TestData_Account_V1.resource ├── Datatable_TestData_Account_V1.resource-meta.xml ├── Datatable_TestData_Contact_V1.resource ├── Datatable_TestData_Contact_V1.resource-meta.xml ├── SLDS24.resource └── SLDS24.resource-meta.xml /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 ramanathan pachaiyappan 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # salesforce-lightning-datatable 2 | Simple Datatable which takes SOQL query and creates native lightning datatables. Refer wiki https://github.com/ramanathansj/salesforce-lightning-datatable/wiki 3 | -------------------------------------------------------------------------------- /images/appbuilderconfig.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramanathansj/salesforce-lightning-datatable/b519b886e6b552b7f160b8cd6c605a5e273c16c6/images/appbuilderconfig.PNG -------------------------------------------------------------------------------- /images/datatableedit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramanathansj/salesforce-lightning-datatable/b519b886e6b552b7f160b8cd6c605a5e273c16c6/images/datatableedit.PNG -------------------------------------------------------------------------------- /images/datatableview.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramanathansj/salesforce-lightning-datatable/b519b886e6b552b7f160b8cd6c605a5e273c16c6/images/datatableview.PNG -------------------------------------------------------------------------------- /src/aura/DataTableApp/DataTableApp.app: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 11 | 12 | 13 |
14 |
-------------------------------------------------------------------------------- /src/aura/DataTableApp/DataTableApp.app-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/DataTableApp/DataTableApp.auradoc: -------------------------------------------------------------------------------- 1 | 2 | Documentation 3 | 4 | -------------------------------------------------------------------------------- /src/aura/DataTableApp/DataTableAppController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | 3 | }) -------------------------------------------------------------------------------- /src/aura/DataTableApp/DataTableAppHelper.js: -------------------------------------------------------------------------------- 1 | ({ 2 | 3 | }) -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2.auradoc: -------------------------------------------------------------------------------- 1 | 2 | Documentation 3 | 4 | Simple implementation of datatable which converts SOQL query into datatable 5 | 6 | -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 |
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 89 | 90 | 91 | 92 | 93 | 94 |
57 | 58 | Sort 59 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | Sorted {!if(v.ascDescVal == 'asc', 'ascending', 'descending')} 69 |
70 |
81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
95 |
96 | 97 |
98 | 99 |
100 |
101 | 102 |
-------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2.design: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2Controller.js: -------------------------------------------------------------------------------- 1 | ({ 2 | doInit: function(cmp,event,helper) { 3 | if (cmp.isValid()) { 4 | //helper.queryFieldsFomrat(cmp); 5 | var whereCls = cmp.get("v.whereclause"); 6 | if (cmp.get("v.isRelatedList") === true && whereCls && whereCls.trim().length > 0) { 7 | whereCls = whereCls.toLowerCase().replace('{recordid}', '\''+cmp.get("v.recordId")+'\''); 8 | cmp.set("v.whereclause", whereCls); 9 | } 10 | helper.queryRows(cmp, 0, helper.getSortOrder(cmp, false)); 11 | } 12 | }, 13 | pagerecords : function (cmp,event,helper) { 14 | if (cmp.isValid()) { 15 | cmp.set("v.page", event.getParam("pagevalue")); 16 | helper.queryRows(cmp, cmp.get("v.page") || 0, helper.getSortOrder(cmp, false)); 17 | } 18 | }, 19 | customSort : function(cmp,event,helper) { 20 | if (cmp.isValid()) { 21 | cmp.set("v.sortField", event.getParam("fieldid")); 22 | cmp.set("v.page", event.getParam("pagevalue")); 23 | helper.queryRows(cmp, cmp.get("v.page") || 0, helper.getSortOrder(cmp, true)); 24 | } 25 | }, 26 | showSpinner : function (component, event, helper) { 27 | if (component.isValid()) component.set("v.showspinner", true); 28 | }, 29 | hideSpinner : function (component, event, helper) { 30 | if (component.isValid()) component.set("v.showspinner", false); 31 | }, 32 | showEdit : function (component, event, helper) { 33 | try { 34 | if (component.isValid()) { 35 | component.set("v.edit", 1); 36 | helper.queryRows(component, component.get("v.page") || 0, helper.getSortOrder(component, false)); 37 | } 38 | } catch (e) { 39 | console.log("mode == "+e); 40 | throw new Error("error occured refresh page!!"+e); 41 | } 42 | }, 43 | cancelEdit : function (component, event, helper) { 44 | try { 45 | if (component.isValid()) { 46 | component.set("v.edit", 0); 47 | helper.queryRows(component, component.get("v.page") || 0, helper.getSortOrder(component, false)); 48 | } 49 | } catch (e) { 50 | console.log("mode == "+e); 51 | throw new Error("error occured refresh page!!"); 52 | } 53 | }, 54 | saveRecords : function (component, event, helper) { 55 | helper.bulkSaveRecords(component, event, helper); 56 | } 57 | }) -------------------------------------------------------------------------------- /src/aura/DataTableV2/DataTableV2Helper.js: -------------------------------------------------------------------------------- 1 | ({ 2 | queryRows : function(component, page, sOrder) { 3 | var action = component.get("c.getSobjects"); 4 | //console.log("=== fields ===="+fields); 5 | var params = { "columnfields": component.get("v.columnfields"), "objName": component.get("v.object"), "currentPage": page, "lim": component.get("v.pagelimit") || 10 6 | ,"sortField" : component.get("v.sortField"), "sortOrder" : sOrder || "asc" , "whereCls":component.get("v.whereclause") }; 7 | console.log(JSON.stringify(params)); 8 | action.setParams(params); 9 | action.setCallback(this, function(response) { 10 | console.log(response.getState()); 11 | if (response && response.getState() === "SUCCESS" && component.isValid()) { 12 | var recordset = response.getReturnValue(); 13 | if (component.get("v.columns").length <= 0) { 14 | component.set("v.columns", recordset.columnHeader); 15 | } 16 | console.log(recordset.rows); 17 | component.set("v.results", recordset.rows); 18 | component.set("v.resultsetsize", recordset.size); 19 | } 20 | }); 21 | $A.enqueueAction(action); 22 | }, 23 | getSortOrder : function(cmp, changeorder) { 24 | if (changeorder && changeorder === true) { 25 | if (cmp.get("v.ascDescVal") === "asc") { 26 | cmp.set("v.ascDescVal", "desc"); 27 | } else if (cmp.get("v.ascDescVal") === "desc") { 28 | cmp.set("v.ascDescVal", "asc"); 29 | } else { 30 | cmp.set("v.ascDescVal", "desc"); 31 | } 32 | } 33 | return cmp.get("v.ascDescVal"); 34 | }, 35 | bulkSaveRecords: function(component, event, helper) { 36 | var action = component.get("c.bulkSaveRecords"); 37 | var records = component.get("v.results"); 38 | for (var i=0; i< records.length; i+=1) { 39 | console.log("record = "+JSON.stringify(records[i])); 40 | } 41 | action.setParams({"rowJSON":JSON.stringify(records), "obName":component.get("v.object")}); 42 | action.setCallback(this, function(response) { 43 | if (response && response.getState() === "SUCCESS") { 44 | //console.log("bulksave resp = "+response.getReturnValue()); 45 | var resultRsp = JSON.parse(response.getReturnValue()); 46 | var erroroccured = false; 47 | for (var i=0; i 0) { 49 | erroroccured = true; 50 | } 51 | } 52 | //console.log("resultRsp == "+JSON.stringify(resultRsp)); 53 | if (!erroroccured) { 54 | component.set("v.messages", "Record Saved Successfully"); 55 | component.set("v.status", "success"); 56 | } else if (erroroccured === true) { 57 | component.set("v.messages", "Error Occurred! Contact Your Administrator or Check Console Logs!"); 58 | component.set("v.status", "fail"); 59 | } 60 | } 61 | }); 62 | $A.enqueueAction(action); 63 | } 64 | }) -------------------------------------------------------------------------------- /src/aura/DatatableLntgOut/DatatableLntgOut.app: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/aura/DatatableLntgOut/DatatableLntgOut.app-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/MyOutputClickEvt/MyOutputClickEvt.evt: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/aura/MyOutputClickEvt/MyOutputClickEvt.evt-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputField.auradoc: -------------------------------------------------------------------------------- 1 | 2 | Documentation 3 | 4 | Example Description 5 | 6 | -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputField.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {!v.value} 7 | 8 | {!v.body} 9 | -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputField.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputField.css: -------------------------------------------------------------------------------- 1 | .THIS { 2 | } -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputFieldController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | click : function(component, event, helper) { 3 | var clickEvt = $A.get("e.c:MyOutputClickEvt"); 4 | clickEvt.setParams({ "fieldid":component.get("v.recordid")}); 5 | clickEvt.fire(); 6 | } 7 | }) -------------------------------------------------------------------------------- /src/aura/MyOutputField/MyOutputFieldHelper.js: -------------------------------------------------------------------------------- 1 | ({ 2 | helperMethod : function() { 3 | 4 | } 5 | }) -------------------------------------------------------------------------------- /src/aura/Pagination/Pagination.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 | 19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 |
-------------------------------------------------------------------------------- /src/aura/Pagination/Pagination.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/Pagination/Pagination.css: -------------------------------------------------------------------------------- 1 | .THIS { 2 | } -------------------------------------------------------------------------------- /src/aura/Pagination/Pagination.design: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/aura/Pagination/PaginationController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | paginate : function(component, event, helper) { 3 | if (component.isValid()) helper.pageRecords(component, event, helper); 4 | }, 5 | doneRerender : function (component, event, helper) { 6 | if (component.isValid()) helper.removeBtnCSS(component); 7 | }, 8 | changepage : function (component, event, helper) { 9 | if (component.isValid()) { 10 | var selectcmp = component.find('selectpageid'); 11 | var pagelimit = parseInt(selectcmp.getElement().value, 10); 12 | if (pagelimit) { 13 | component.set("v.pagelimit", pagelimit); 14 | helper.pageRecords(component, event, helper, true); 15 | } 16 | //console.log(selectcmp.getElement().value ); 17 | } 18 | } 19 | }) -------------------------------------------------------------------------------- /src/aura/Pagination/PaginationHelper.js: -------------------------------------------------------------------------------- 1 | ({ 2 | removeBtnCSS: function(component) { 3 | $A.util.removeClass(component.find('first'),'uiButton--default uiButton'); 4 | $A.util.removeClass(component.find('previous'),'uiButton--default uiButton'); 5 | $A.util.removeClass(component.find('next'),'uiButton--default uiButton'); 6 | $A.util.removeClass(component.find('last'),'uiButton--default uiButton'); 7 | }, 8 | 9 | pageRecords : function(component, event, helper, flag) { 10 | var buttonval = ""; 11 | if (flag === true) { 12 | buttonval = "first"; 13 | } else { 14 | buttonval = event.getSource().getLocalId().toLowerCase(); 15 | } 16 | console.log("buttonval = "+buttonval); 17 | if (buttonval) { 18 | var pagelimit = component.get("v.pagelimit"), offsetvalue = component.get("v.offset"), 19 | totalrows = component.get("v.resultsetsize"); 20 | //console.log("resultsetsize = "+totalrows); 21 | if (buttonval === "first") { 22 | offsetvalue = 0; 23 | component.set("v.isLast", false); 24 | } else if (buttonval === "previous") { 25 | offsetvalue = (offsetvalue - pagelimit) * 1; 26 | component.set("v.isLast", false); 27 | } 28 | else if (buttonval === "last" || buttonval === "next") { 29 | if (totalrows > (offsetvalue + pagelimit) && buttonval === "next") { 30 | offsetvalue = (offsetvalue + pagelimit) * 1; 31 | component.set("v.isLast", false); 32 | } 33 | if (buttonval === "last" || totalrows <= (offsetvalue + pagelimit) ) { 34 | var currentpage = (totalrows % pagelimit) > 0 ? Math.floor(totalrows / pagelimit) + 1 : Math.floor(totalrows / pagelimit); 35 | //console.log("last page = "+currentpage); 36 | offsetvalue = (currentpage - 1) * pagelimit * 1; 37 | component.set("v.isLast", true); 38 | } 39 | } 40 | //console.log("offsetvalue = "+offsetvalue); 41 | component.set("v.offset", offsetvalue); 42 | var pageEvt = $A.get("e.c:PaginationEvent"); 43 | pageEvt.setParams({ "pagevalue":offsetvalue}); 44 | pageEvt.fire(); 45 | } 46 | } 47 | }) -------------------------------------------------------------------------------- /src/aura/Pagination/PaginationRenderer.js: -------------------------------------------------------------------------------- 1 | ({ 2 | // Your renderer method overrides go here 3 | afterRender: function (component, helper) { 4 | if (component.isValid()) { 5 | this.superAfterRender(); 6 | helper.removeBtnCSS(component); 7 | } 8 | 9 | } 10 | }) -------------------------------------------------------------------------------- /src/aura/PaginationEvent/PaginationEvent.evt: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/aura/PaginationEvent/PaginationEvent.evt-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/Spinner/Spinner.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /src/aura/Spinner/Spinner.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | custom spinner 5 | 6 | -------------------------------------------------------------------------------- /src/aura/Spinner/Spinner.css: -------------------------------------------------------------------------------- 1 | .THIS { 2 | } -------------------------------------------------------------------------------- /src/aura/Toast/Toast.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 17 |
18 |
19 |
-------------------------------------------------------------------------------- /src/aura/Toast/Toast.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/Toast/ToastController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | destory : function(component, event, helper) { 3 | console.log("timeouts = "+component.get("v.timeoutMS")); 4 | if (component.get("v.message") && component.get("v.message").length > 0) { 5 | window.setTimeout( 6 | $A.getCallback(function() { 7 | if (component.isValid()) { 8 | component.set("v.message", ""); 9 | } 10 | }), component.get("v.timeoutMS") 11 | ); 12 | } 13 | } 14 | }) -------------------------------------------------------------------------------- /src/aura/Toast/ToastRenderer.js: -------------------------------------------------------------------------------- 1 | ({ 2 | // Your renderer method overrides go here 3 | }) -------------------------------------------------------------------------------- /src/aura/inputField/inputField.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {!v.cell.fieldValue} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {!v.cell.fieldValue}" 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | {!v.cell.fieldValue}" 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {!v.cell.fieldValue} 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/aura/inputField/inputField.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /src/aura/inputField/inputField.css: -------------------------------------------------------------------------------- 1 | .THIS { 2 | } -------------------------------------------------------------------------------- /src/aura/outputField/outputField.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | {!v.cell.fieldValue} 20 | 21 | -------------------------------------------------------------------------------- /src/aura/outputField/outputField.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | An custom output field similar to fields available in visualforce framework 5 | 6 | -------------------------------------------------------------------------------- /src/aura/svg/svg.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {!v.assistiveText} 11 | 12 | -------------------------------------------------------------------------------- /src/aura/svg/svg.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36.0 4 | custom svg componenet 5 | 6 | -------------------------------------------------------------------------------- /src/aura/svg/svg.css: -------------------------------------------------------------------------------- 1 | .THIS { 2 | } -------------------------------------------------------------------------------- /src/aura/svg/svgController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | 3 | }) -------------------------------------------------------------------------------- /src/aura/svg/svgHelper.js: -------------------------------------------------------------------------------- 1 | ({ 2 | renderIcon: function(component) { 3 | var prefix = "slds-"; 4 | var svgns = "http://www.w3.org/2000/svg"; 5 | var xlinkns = "http://www.w3.org/1999/xlink"; 6 | var size = component.get("v.size"); 7 | var name = component.get("v.name"); 8 | var classname = component.get("v.class"); 9 | var containerclass = component.get("v.containerClass"); 10 | var category = component.get("v.category"); 11 | 12 | var containerClassName = [ 13 | prefix+"icon_container", 14 | prefix+"icon-"+category+"-"+name, 15 | containerclass 16 | ].join(' '); 17 | component.set("v.containerClass", containerClassName); 18 | 19 | var svgroot = document.createElementNS(svgns, "svg"); 20 | var iconClassName = prefix+"icon "+prefix+"icon--" + size+" "+classname; 21 | svgroot.setAttribute("aria-hidden", "true"); 22 | svgroot.setAttribute("class", iconClassName); 23 | svgroot.setAttribute("name", name); 24 | 25 | // Add an "href" attribute (using the "xlink" namespace) 26 | var shape = document.createElementNS(svgns, "use"); 27 | shape.setAttributeNS(xlinkns, "href", component.get("v.svgPath")); 28 | svgroot.appendChild(shape); 29 | 30 | var container = component.find("container").getElement(); 31 | container.insertBefore(svgroot, container.firstChild); 32 | } 33 | }) -------------------------------------------------------------------------------- /src/aura/svg/svgRenderer.js: -------------------------------------------------------------------------------- 1 | ({ 2 | // Your renderer method overrides go here 3 | render: function(component, helper) { 4 | // By default, after the component finished loading data/handling events, 5 | // it will call this render function this.superRender() will call the 6 | // render function in the parent component. 7 | var ret = this.superRender(); 8 | 9 | // Calls the helper function to append the SVG icon 10 | helper.renderIcon(component); 11 | return ret; 12 | } 13 | }) -------------------------------------------------------------------------------- /src/classes/DataTableController.cls: -------------------------------------------------------------------------------- 1 | /* @author Ram 2 | * @desc Simple controller class for datatable backend 3 | * Date 1/2/17 4 | */ 5 | public class DataTableController { 6 | 7 | @AuraEnabled 8 | public static ResultSet getSobjects(String columnfields, String objName, Integer currentPage, Integer lim, String sortField, String sortOrder, String whereCls) { 9 | ResultSet results = null; 10 | try { 11 | List fields = splitQStr(columnfields); 12 | //get total rows 13 | String countQuery = 'Select count()'+' From '+objName; 14 | countQuery = String.isNotBlank(whereCls) ? countQuery + ' where '+whereCls : countQuery; 15 | System.debug(Logginglevel.info, 'countQuery ===== '+countQuery); 16 | Integer totalRows = Database.countQuery(countQuery+ ' LIMIT 50000'); 17 | //get records 18 | String query = 'Select '+String.join(fields, ',')+' From '+ objName; 19 | query = String.isNotBlank(whereCls) ? query + ' where '+whereCls : query; 20 | query = query +' order by '+sortField+' '+sortOrder+' LIMIT '+lim +' Offset '+ currentPage; 21 | System.debug(Logginglevel.info, 'Full Query ===== '+query); 22 | List sObjects = Database.query(query); 23 | //System.debug(Logginglevel.info, 'objects ===== '+sObjects); 24 | results = processResults(fields, objName, sObjects, totalRows); 25 | } catch (Exception ex) { 26 | throw new DatatableException(' Error Occured! '+ex.getMessage()); 27 | } 28 | return results; 29 | } 30 | 31 | private static ResultSet processResults(List fields, String objName, List sObjects, Integer totalRows) { 32 | List rows = new List(); 33 | Map fieldType = DataTableController.describeFields(objName); 34 | List colNames = new List(); 35 | for (String fld : fields) { 36 | if (String.isEmpty(fld)) continue; 37 | fld = fld.trim().toLowerCase(); 38 | //System.debug(logginglevel.info,'fld = '+fld); 39 | if (fld.containsAny('(') || fld.containsAny('((')) { 40 | fld = fld.substring(fld.lastIndexOfIgnoreCase('(')+1, fld.IndexOfIgnoreCase(')')).trim(); 41 | System.debug(logginglevel.info, 'formatted field == '+fld); 42 | } 43 | //System.debug(logginglevel.info,'fld = '+fld+', fieldType.get(fld) = '+fieldType.get(fld).getType().name()); 44 | //System.debug(logginglevel.info,'fieldType.get(fld).getLabel = '+fieldType.get(fld)); 45 | String flabel = fld.contains('.') ? getRelatedObjectFieldLabel(fld, fieldType) : fieldType.get(fld).getLabel(); 46 | //System.debug(logginglevel.info,'fld = '+fld+ 'flabel == '+flabel+', fieldType.get(fld) = '+fieldType.get(fld).getType().name()); 47 | colNames.add(new Cell(fld, flabel, (!fld.contains('.') ? fieldType.get(fld).getType().name() : 'REFERENCE'), null, false)); 48 | } 49 | for(sObject temp : sObjects) { 50 | //Map obj = temp.getPopulatedFieldsAsMap(); 51 | List cols = new List(); 52 | for (String fld : fields) { 53 | fld = fld.trim().toLowerCase(); 54 | Cell col; 55 | System.debug(logginglevel.info,'fld = '+fld+'fieldType.get(fld)= '+fieldType.get(fld)); 56 | List pickVals = new List(); 57 | if (fieldType.get(fld) !=null && fieldType.get(fld).getType().name().equalsIgnoreCase('picklist') && fieldType.get(fld) != null) pickVals = getPicklistValues(fieldType.get(fld).getPicklistValues()); 58 | 59 | if (fld.containsAny('(') || fld.containsAny('((')) { 60 | fld = fld.substring(fld.lastIndexOfIgnoreCase('(')+1, fld.IndexOfIgnoreCase(')')).trim(); 61 | } 62 | if (fld.contains('.')) { 63 | Object fieldVal = getRelatedObjectFieldValue(fld, temp); 64 | col = new Cell(fld, fieldVal, 'REFERENCE', pickVals, false); //update based object only in release one 65 | } else if (temp.get(fld) != null){ 66 | col = new Cell(fld, temp.get(fld), fieldType.get(fld).getType().name(), pickVals, fieldType.get(fld).isUpdateable()); 67 | } else { 68 | col = new Cell(fld, '', fieldType.get(fld).getType().name(), pickVals, fieldType.get(fld).isUpdateable()); 69 | } 70 | System.debug(logginglevel.info, 'data cell ==== '+col); 71 | cols.add(col); 72 | } 73 | rows.add(new Row(cols)); 74 | } 75 | return new ResultSet(rows, totalRows, colNames, objName); 76 | } 77 | 78 | private static Map describeFields(String objName) { 79 | Schema.DescribeSobjectResult[] results = Schema.describeSObjects(new List{objName}); 80 | Map childObjects = new Map(); 81 | Map fieldResults = new Map(); 82 | //describe object 83 | for(Schema.SObjectField field : results[0].fields.getMap().values()) { 84 | Schema.DescribeFieldResult fResult = field.getDescribe(); 85 | System.debug(logginglevel.info, 'fResult.getName() == '+fResult.getName().toLowerCase()+', fResult = '+fResult); 86 | fieldResults.put(fResult.getName().toLowerCase(), fResult); 87 | } 88 | return fieldResults; 89 | } 90 | 91 | private static String formatLookupFieldAPI(String ref, boolean flag) { 92 | String lookupApi = ''; 93 | if (String.isNotBlank(ref)) { 94 | lookupApi = ref.trim().endsWithIgnoreCase('__r') ? ref.removeEndIgnoreCase('__r')+'__c' : ref.trim();//'Id' 95 | lookupApi = flag && !lookupApi.endsWithIgnoreCase('__c') ? lookupApi+'id' : lookupApi; 96 | } 97 | return lookupApi; 98 | } 99 | 100 | private static Object getRelatedObjectFieldValue(String relationshipField, sObject resultObj) { 101 | Object result; 102 | if (String.isNotBlank(relationshipField) && resultObj != null) { 103 | List tempLevels = relationshipField.split('\\.'); 104 | String findRelField = tempLevels[tempLevels.size()-1]; 105 | tempLevels.remove(tempLevels.size()-1); 106 | for (Integer i=0; i fieldResults) { 115 | List tempLevels = relationshipField.split('\\.'); 116 | String findRelField = tempLevels[tempLevels.size()-1]; 117 | tempLevels.remove(tempLevels.size()-1); 118 | for (Integer i=0; i returnObj = objResult.getReferenceTo(); 139 | return returnObj != null && returnObj.size() > 0 ? returnObj[0] : null; 140 | } 141 | 142 | private static List splitQStr(String flds) { 143 | Set fields = new Set(); 144 | boolean idFound = false; 145 | if (String.isNotBlank(flds)) { 146 | for (String fld : flds.split(',')) { 147 | if (String.isNotBlank(fld)) { 148 | fields.add(fld.trim()); 149 | if (fld.trim().equalsIgnoreCase('id')) idFound = true; 150 | } 151 | } 152 | } 153 | if (!idFound) fields.add('Id'); 154 | return new List(fields); 155 | } 156 | 157 | private static List getPicklistValues(List pickEntries) { 158 | List pickVals = new List(); 159 | for (Schema.PicklistEntry pick : pickEntries) { 160 | pickVals.add(pick.getValue()); 161 | } 162 | return pickVals; 163 | } 164 | 165 | @AuraEnabled 166 | public static String bulkSaveRecords(String rowJSON, String obName) { 167 | System.debug(logginglevel.info , 'rows ======= '+rowJSON); 168 | List rows = (List) JSON.deserializeUntyped(rowJSON); 169 | List sObjectsToUpdate = new List(); 170 | for (Object temp : rows) { 171 | Map objVal = (Map) temp; 172 | for (String key : objVal.keySet()) { 173 | List objVal2 = (List) objVal.get(key); 174 | sObject objRecord = Schema.getGlobalDescribe().get(obName).newSObject(); 175 | for (Object row : objVal2) { 176 | Map obMap = (Map) row; 177 | //System.debug('object '+obMap); 178 | try { 179 | parseFieldValues(obMap, objRecord); 180 | } catch (Exception ex) { 181 | throw new DatatableException(' Error Occured! '+ex.getMessage()); 182 | } 183 | } 184 | if (objRecord.get('id') != null ) sObjectsToUpdate.add(objRecord); 185 | System.debug('sobject ============== '+objRecord); 186 | } 187 | } 188 | System.debug('sObjectsToUpdate ============== '+sObjectsToUpdate); 189 | Database.SaveResult[] results = new List(); 190 | results = Database.update(sObjectsToUpdate, true); 191 | return JSON.serialize(results); 192 | } 193 | 194 | private static void parseFieldValues(Map obMap, sObject objRecord) { 195 | if ((Boolean.valueOf(obMap.get('isWritable')) || String.valueOf(obMap.get('fieldApi')).equalsIgnoreCase('Id')) && String.isNotBlank(String.valueOf(obMap.get('fieldValue')))) { 196 | String dataType = String.Valueof(obMap.get('fieldType')); 197 | //System.debug('dataType === '+dataType); 198 | if (dataType.equalsIgnoreCase('Currency') || dataType.equalsIgnoreCase('Percent')) { 199 | objRecord.put(String.Valueof(obMap.get('fieldApi')), Decimal.valueOf(String.valueOf(obMap.get('fieldValue')))); 200 | } 201 | else if (dataType.equalsIgnoreCase('Date')) { 202 | objRecord.put(String.Valueof(obMap.get('fieldApi')), Date.valueOf(String.ValueOf(obMap.get('fieldValue')))); 203 | } 204 | else if (dataType.equalsIgnoreCase('DateTime')) { 205 | System.debug(logginglevel.INFO, obMap.get('fieldApi')+'datetime before === '+obMap.get('fieldValue')); 206 | Datetime dt = (Datetime)JSON.deserialize(String.valueOf(obMap.get('fieldValue')).trim(), Datetime.class); 207 | //Datetime dt = Datetime.valueOf(String.valueOf(obMap.get('fieldValue')).replace('T', ' ').replace('Z', '').trim()); 208 | System.debug(logginglevel.INFO,'datetime after === '+dt); 209 | objRecord.put(String.Valueof(obMap.get('fieldApi')), dt); 210 | } 211 | else if (dataType.equalsIgnoreCase('Double')){ 212 | objRecord.put(String.Valueof(obMap.get('fieldApi')), Double.valueOf(obMap.get('fieldValue'))); 213 | } 214 | else if (dataType.equalsIgnoreCase('Integer')){ 215 | objRecord.put(String.Valueof(obMap.get('fieldApi')), Integer.valueOf(obMap.get('fieldValue'))); 216 | } 217 | else { 218 | objRecord.put(String.Valueof(obMap.get('fieldApi')), obMap.get('fieldValue')); 219 | } 220 | } 221 | } 222 | 223 | 224 | public class Cell { 225 | @AuraEnabled public String fieldApi {get; set;} 226 | @AuraEnabled public String fieldType {get; set;} 227 | @AuraEnabled public Object fieldValue {get; set;} 228 | @AuraEnabled public Long unixTime {get; set;} 229 | @AuraEnabled public Decimal currencyVal {get; set;} 230 | @AuraEnabled public List pickValues {get; set;} 231 | @AuraEnabled public boolean isWritable {get; set;} 232 | 233 | 234 | public Cell (String fApi, Object fVal, String fType, List pickVal, boolean readOnly) { 235 | this.fieldApi = fApi; 236 | this.fieldType = fType; 237 | this.fieldValue = fVal; 238 | this.isWritable = readOnly; 239 | this.pickValues = pickVal; 240 | if (fType.equalsIgnoreCase('datetime') && this.fieldValue instanceof Datetime && this.fieldValue !=null) { 241 | //System.debug(logginglevel.info, 'fieldValue ==== '+fieldValue); 242 | Datetime temp = Datetime.valueOf(this.fieldValue); 243 | this.unixTime = temp.getTime(); 244 | } 245 | if (fType.equalsIgnoreCase('currency') && this.fieldValue instanceof Decimal && this.fieldValue !=null) { 246 | ///System.debug(logginglevel.info, 'fieldValue ==== '+fieldValue); 247 | this.currencyVal = (Decimal)this.fieldValue; 248 | } 249 | } 250 | } 251 | 252 | public class Row { 253 | @AuraEnabled public List fields {get; set;} 254 | 255 | public Row(List cols) { 256 | this.fields = cols; 257 | } 258 | } 259 | 260 | public class ResultSet { 261 | @AuraEnabled public List rows {get; set;} 262 | @AuraEnabled public Integer size {get; set;} 263 | @AuraEnabled public List columnHeader {get; set;} 264 | 265 | public ResultSet(List rw, Integer siz, List ch, String obName) { 266 | this.rows = rw; 267 | this.size = siz; 268 | this.columnHeader = ch; 269 | } 270 | } 271 | 272 | public class DatatableException extends Exception { } 273 | 274 | } -------------------------------------------------------------------------------- /src/classes/DataTableController.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /src/classes/DataTableController_Test.cls: -------------------------------------------------------------------------------- 1 | @isTest 2 | private class DataTableController_Test { 3 | 4 | @testSetup static void setup() { 5 | System.runAs(createUser('batman@darkknightrises.com')) { 6 | List accounts = Test.loadData(Account.sObjectType, 'Datatable_TestData_Account_V1'); 7 | System.assert(accounts.size() > 0); 8 | List contacts = Test.loadData(Contact.sObjectType, 'Datatable_TestData_Contact_V1'); 9 | System.assert(contacts.size() > 0); 10 | } 11 | } 12 | 13 | @isTest static void testAccountRecords() { 14 | System.runAs(createUser('batman@darkknightrises.com')) { 15 | String fields = 'Name, Title, LeadSource, Account.Name, Description, LastModifiedDate'; 16 | DataTableController.ResultSet results = DataTableController.getSobjects(fields, 'Contact', 0, 10, 'Name', 'asc', ''); 17 | System.assert(results != null); 18 | System.assert(results.columnHeader.size() > 0); 19 | System.assert(results.rows.size() > 0); 20 | } 21 | } 22 | 23 | @isTest static void testBulkSave() { 24 | System.runAs(createUser('batman@darkknightrises.com')) { 25 | String fields = 'Id, Name, Title, Account.Name, Firstname,LastModifiedDate'; 26 | DataTableController.ResultSet results = DataTableController.getSobjects(fields, 'Contact', 0, 10, 'Name', 'asc', ''); 27 | System.assert(results != null); 28 | for (DataTableController.Row re : results.rows) { 29 | for (DataTableController.Cell ce : re.fields) { 30 | if (ce.fieldApi.equalsIgnoreCase('Firstname')) ce.fieldValue = 'Test'+ce.fieldValue; 31 | } 32 | } 33 | String jsonData = JSON.serialize(results.rows); 34 | System.debug(logginglevel.info, 'jsonData === '+jsonData); 35 | String response = DataTableController.bulkSaveRecords(jsonData, 'Contact'); 36 | System.debug(logginglevel.info, 'response === '+response); 37 | Database.SaveResult[] saveResults = (List) JSON.deserializeStrict(response, List.class); 38 | for (Database.SaveResult r : saveResults) { 39 | System.assert(r.isSuccess()); 40 | } 41 | } 42 | } 43 | 44 | static User createUser(String email) { 45 | List usrs = new List(); 46 | usrs = [Select Id From User where Email =:email]; 47 | User usr; 48 | if (usrs.isEmpty()) { 49 | Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 50 | usr = new User(Alias = 'usr123', Email = email, EmailEncodingKey='UTF-8', FirstName ='Test1', LastName='Testing', 51 | LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, 52 | TimeZoneSidKey='America/Los_Angeles', UserName = email+'.test.qa123'); 53 | } else { 54 | usr = usrs[0]; 55 | } 56 | return usr; 57 | } 58 | } -------------------------------------------------------------------------------- /src/classes/DataTableController_Test.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /src/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DataTableController 5 | DataTableController_Test 6 | ApexClass 7 | 8 | 9 | Datatable 10 | ApexPage 11 | 12 | 13 | DataTableApp 14 | DataTableV2 15 | DatatableLntgOut 16 | MyOutputClickEvt 17 | MyOutputField 18 | Pagination 19 | PaginationEvent 20 | Spinner 21 | Toast 22 | inputField 23 | outputField 24 | svg 25 | AuraDefinitionBundle 26 | 27 | 28 | Datatable_TestData_Account_V1 29 | Datatable_TestData_Contact_V1 30 | SLDS24 31 | StaticResource 32 | 33 | 36.0 34 | 35 | -------------------------------------------------------------------------------- /src/pages/Datatable.page: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 14 | -------------------------------------------------------------------------------- /src/pages/Datatable.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | false 5 | false 6 | 7 | 8 | 1 9 | 61 10 | agf 11 | 12 | 13 | 1 14 | 19 15 | awduplicate 16 | 17 | 18 | 3 19 | 5 20 | dsfs 21 | 22 | 23 | 2 24 | 2 25 | fliptop 26 | 27 | 28 | 1 29 | 0 30 | myaura 31 | 32 | 33 | 1 34 | 0 35 | oauthplayground 36 | 37 | 38 | 1 39 | 2 40 | permissioner 41 | 42 | 43 | 1 44 | 3 45 | privateAppEx 46 | 47 | 48 | 3 49 | 6 50 | s4g_currencies 51 | 52 | 53 | 1 54 | 6 55 | sf_chttr_apps 56 | 57 | 58 | 1 59 | 6 60 | sf_com_apps 61 | 62 | 63 | 1 64 | 0 65 | soql_explain 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/staticresources/Datatable_TestData_Account_V1.resource: -------------------------------------------------------------------------------- 1 | "ID","NAME","TYPE","BILLINGSTREET","BILLINGCITY","BILLINGSTATE","BILLINGPOSTALCODE","BILLINGCOUNTRY","SHIPPINGSTREET","SHIPPINGCITY","SHIPPINGSTATE","SHIPPINGPOSTALCODE","SHIPPINGCOUNTRY","PHONE","ACCOUNTNUMBER","WEBSITE","INDUSTRY" 2 | "001U0000003MhzcIAC","University of Arizona123","Customer - Direct","888 N Euclid 3 | Hallis Center, Room 501 4 | Tucson, AZ 85721 5 | United States","Tucson","AZ","","USA","888 N Euclid 6 | Hallis Center, Room 501 7 | Tucson, AZ 85721 8 | United States","","","","","(520) 773-9050","CD736025","www.universityofarizona.com","Education" 9 | "001U0000003MhzdIAC","United Oil & Gas Corp.123","Customer - Direct","1301 Avenue of the Americas 10 | New York, NY 10019 11 | USA","New York","NY","","USA","1301 Avenue of the Americas 12 | New York, NY 10019 13 | USA","","","","","(212) 842-5500","CD355118","http://www.uos.com","Energy" 14 | "001U0000003MhzeIAC","sForce","Customer - Direct","The Landmark @ One Market","San Francisco","CA","94087","US","","","","","","(415) 901-7000","","www.sforce.com","Hospitality" 15 | "001U0000003MhzTIAS","GenePoint","Customer - Channel","345 Shoreline Park 16 | Mountain View, CA 94043 17 | USA","Mountain View","CA","","USA","345 Shoreline Park 18 | Mountain View, CA 94043 19 | USA","","","","","(650) 867-3450","CC978213","www.genepoint.com","Biotechnology" 20 | "001U0000003MhzUIAS","United Oil & Gas, UK123","Customer - Direct","Kings Park, 17th Avenue, Team Valley Trading Estate, 21 | Gateshead, Tyne and Wear NE26 3HS 22 | United Kingdom","","UK","","USA","Kings Park, 17th Avenue, Team Valley Trading Estate, 23 | Gateshead, Tyne and Wear NE26 3HS 24 | United Kingdom","","","","","+44 191 4956203","CD355119-A","http://www.uos.com","Biotechnology" 25 | "001U0000003MhzVIAS","United Oil & Gas, Singapore123","Customer - Direct","9 Tagore Lane 26 | Singapore, Singapore 787472 27 | Singapore","Singapore","Singapore","","USA","9 Tagore Lane 28 | Singapore, Singapore 787472 29 | Singapore","","","","","(650) 450-8810","CD355120-B","http://www.uos.com","Energy" 30 | "001U0000003MhzWIAS","Edge Communications123","Customer - Direct","312 Constitution Place 31 | Austin, TX 78767 32 | USA","Austin","TX","","USA","312 Constitution Place 33 | Austin, TX 78767 34 | USA","","","","","(512) 757-6000","CD451796","http://edgecomm.com","Electronics" 35 | "001U0000003MhzXIAS","Burlington Textiles Corp of America123","Customer - Direct","525 S. Lexington Ave","Burlington","NC","27215","USA","","","","","","(336) 222-7000","CD656092","www.burlington.com","Apparel" 36 | "001U0000003MhzYIAS","Pyramid Construction Inc.123","Customer - Channel","2 Place Jussieu","Paris","","75251","France","2 Place Jussieu","Paris","","75251","France","(014) 427-4427","CC213425","www.pyramid.com","Manufacturing" 37 | "001U0000003MhzZIAS","Dickenson plc","Customer - Channel","1301 Hoch Drive","Lawrence","KS","66045","USA","1301 Hoch Drive","Lawrence","KS","66045","USA","(785) 241-6200","CC634267","dickenson-consulting.com","Consulting" 38 | "001U0000003MhzaIAC","Grand Hotels & Resorts Ltd 001","Customer - Direct","2334 N. Michigan Avenue, Suite 1500 39 | Chicago, IL 60601, USA","Chicago","IL","","USA","2334 N. Michigan Avenue, Suite 1500 40 | Chicago, IL 60601, USA","","","","","(312) 596-1000","CD439877","www.grandhotels.com","Hospitality" 41 | "001U0000003MhzbIAC","Express Logistics and Transport123","Customer - Channel","620 SW 5th Avenue Suite 400 42 | Portland, Oregon 97204 43 | United States","Portland","OR","","USA","620 SW 5th Avenue Suite 400 44 | Portland, Oregon 97204 45 | United States","","","","","(503) 421-7800","CC947211","www.expressl&t.net","Transportation" 46 | "001U0000002ZpYsIAK","Test My Mobile Company123","","","","","","USA","","","","","","","","","Finance" 47 | "001U000000H08q5IAB","test","","","","","","USA","","","","","","","","","Entertainment" 48 | "001U000001XVSuTIAX","Farmers Coop. of Florida","","321 Westcott Building","Tallahassee","FL","32306","USA","","","","","","(850) 644-4200","","","Agriculture" 49 | "001U000000mGl9aIAC","Zenith Industrial Partners","","","","OH","","USA","","","","","","(614) 431-5000","","","" 50 | "001U000000mGm7jIAC","Aethna Home Products","","","","VA","","USA","","","","","","(434) 369-3100","","","" 51 | -------------------------------------------------------------------------------- /src/staticresources/Datatable_TestData_Account_V1.resource-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private 4 | application/octet-stream 5 | test data for datatable controller 6 | 7 | -------------------------------------------------------------------------------- /src/staticresources/Datatable_TestData_Contact_V1.resource: -------------------------------------------------------------------------------- 1 | "ID","LASTNAME","FIRSTNAME","MAILINGSTREET","MAILINGCITY","MAILINGSTATE","MAILINGPOSTALCODE","MAILINGCOUNTRY","PHONE","EMAIL","TITLE","DEPARTMENT","LEADSOURCE" 2 | "003U00000029EtkIAE","vf1","apex","","","","","","","","","","" 3 | "003U0000002QE8GIAW","Gonzalez","Rose","313 Constitution Place 4 | Austin, TX 78767 5 | USA","","","","","(512) 757-6000","rose@edge.com","SVP, Procurement","Procurement","Trade Show" 6 | "003U0000002QE8HIAW","Forbes","Sean","312 Constitution Place 7 | Austin, TX 78767 8 | USA","","","","","(512) 757-6000","sean@edge.com","CFO","Finance","Trade Show" 9 | "003U0000002QE8IIAW","Rogers","Jack","525 S. Lexington Ave","Burlington","NC","27215","USA","(336) 222-7000","jrogers@burlington.com","VP, Facilities","","Web" 10 | "003U0000002QE8JIAW","Stumuller","Pat","2 Place Jussieu","Paris","","75251","France","(014) 427-4427","rpachaiyappan@gmail.com","SVP, Administration and Finance","Finance","" 11 | "003U0000002QE8KIAW","Young","Andy","1301 Hoch Drive","Lawrence","KS","66045","USA","(785) 241-6200","a_young@dickenson.com","SVP, Operations","Internal Operations","Purchased List" 12 | "003U0000002QE8LIAW","Barr","Tim","2335 N. Michigan Avenue, Suite 1500 13 | Chicago, IL 60601, USA","","","","","(312) 596-1000","barr_tim@grandhotels.com","SVP, Administration and Finance","Finance","External Referral" 14 | "003U0000002QE8MIAW","Bond","John","2334 N. Michigan Avenue, Suite 1500 15 | Chicago, IL 60601, USA","","","","","(312) 596-1000","bond_john@grandhotels.com","VP, Facilities","Facilities","External Referral" 16 | "003U0000002QE8NIAW","Pavlova","Stella","1303 Avenue of the Americas 17 | New York, NY 10019 18 | USA","","","","","(212) 842-5500","spavlova@uog.com","SVP, Production","Production","Public Relations" 19 | "003U0000002QE8OIAW","Boyle","Lauren","1304 Avenue of the Americas 20 | New York, NY 10019 21 | USA","","","","","(212) 842-5500","lboyle@uog.com","SVP, Technology","Technology","Public Relations" 22 | "003U0000002QE8PIAW","Levy","Babara","620 SW 5th Avenue Suite 400 23 | Portland, Oregon 97204 24 | United States","","","","","(503) 421-7800","b.levy@expressl&t.net","SVP, Operations","Operations","Word of mouth" 25 | "003U0000002QE8QIAW","Davis","Josh","621 SW 5th Avenue Suite 400 26 | Portland, Oregon 97204 27 | United States","","","","","(503) 421-7800","j.davis@expressl&t.net","Director, Warehouse Mgmt","Warehouse Mgmt","Word of mouth" 28 | "003U0000002QE8RIAW","Grey","Jane","888 N Euclid 29 | Hallis Center, Room 501 30 | Tucson, AZ 85721 31 | United States","","","","","(520) 773-9050","jane_gray@uoa.edu","Dean of Administration","Administration","Word of mouth" 32 | "003U0000002QE8SIAW","Song","test","1301 Avenue of the Americas 33 | New York, NY 10019 34 | USA","","","","","(212) 842-5500","asong@uog.com","CEO","Executive Team","Public Relations" 35 | "003U0000002QE8TIAW","James","Ashley","Kings Park, 17th Avenue, Team Valley Trading Estate, 36 | Gateshead, Tyne and Wear NE26 3HS 37 | United Kingdom","","","","","+44 191 4956203","ajames@uog.com","VP, Finance","Finance","Public Relations" 38 | "003U0000002QE8UIAW","Ripley","Tom","9 Tagore Lane 39 | Singapore, Singapore 787472 40 | Singapore","","","","","(650) 450-8810","tripley@uog.com","Regional General Manager","Executive Team","Public Relations" 41 | "003U0000002QE8VIAW","D'Cruz","Liz","10 Tagore Lane 42 | Singapore, Singapore 787472 43 | Singapore","","","","","(650) 450-8810","ldcruz@uog.com","VP, Production","Production","Public Relations" 44 | "003U0000002QE8WIAW","Frank","Edna","345 Shoreline Park 45 | Mountain View, CA 94043 46 | USA","","","","","(650) 867-3450","efrank@genepoint.com","VP, Technology","Technology","Partner" 47 | "003U0000002QE8XIAW","Green","Avi","1302 Avenue of the Americas 48 | New York, NY 10019 49 | USA","","","","","(212) 842-5500","agreen@uog.com","CFO","Finance","Public Relations" 50 | "003U0000002QE8YIAW","Nedaerk","Siddartha","The Landmark @ One Market","San Francisco","CA","94087","US","","","","","" 51 | "003U0000002QE8ZIAW","Llorrac","Jake","","","","","","","","","","" 52 | "003U0000002A283IAC","test","ram","","","","","","123-123-1234","rpachaiyappan@gmail.com","","","" 53 | "003U000000KpXndIAF","test","test","","","","","","","","","","" 54 | "003U000001TkKAuIAN","Boxer","Bertha","321 Westcott Building","Tallahassee","FL","32306","USA","(850) 644-4200","bertha@fcof.net","Director of Vendor Relations","","Web" 55 | "003U000001Tl4W3IAJ","Pachaiyappan","Ramanathan","1301 Hoch Drive","Lawrence","KS","66045","USA","(785) 241-6200","","","","" 56 | "003U000001FBJmRIAX","Young","Andy","","","KS","","USA","(620) 241-6200","a_young@dickenson.com","SVP, Operations","","Purchased List" 57 | "003U000000v7YfgIAE","Dadio Jr","Bill","","","OH","","USA","(614) 431-5000","bill_dadio@zenith.com","CFO","","Web" 58 | "003U000000v7Zt6IAE","Akin","Kristen","","","VA","","USA","(434) 369-3100","kakin@athenahome.com","Director, Warehouse Mgmt","","Partner Referral" 59 | -------------------------------------------------------------------------------- /src/staticresources/Datatable_TestData_Contact_V1.resource-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private 4 | application/octet-stream 5 | 6 | -------------------------------------------------------------------------------- /src/staticresources/SLDS24.resource: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramanathansj/salesforce-lightning-datatable/b519b886e6b552b7f160b8cd6c605a5e273c16c6/src/staticresources/SLDS24.resource -------------------------------------------------------------------------------- /src/staticresources/SLDS24.resource-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Public 4 | application/x-zip-compressed 5 | 6 | --------------------------------------------------------------------------------