cms_dual_table

Manage files list table using elFinder file manager
Files list

Note 1: Click to enter ID

Note 2: Click to enter Cache: "caching", "nocache", "inline"

Note 3: Click to enter Life (-1 means unlimited cache life time)

Note 4: Drag and drop to change file order

Trash
 
 

Sample 1:

  • Left side table "ID" cell editable (<input>)
  • Left side table "Caching" cell editable (<select>)
  • Left side table "Cache" cell editable (<input>) with form validation
  • Left side table rows draggable
  • Right side source - elFinder file manager (using CMS access control: in this sample inherits access control list from current page access control list)
  • Button "Save" show left side table content in JSON format
  • Button "Clear" delete all rows from left side table
  • Buttons in the middle: add, remove, add all, remove all

jQuery code snippet:

$.validator.addMethod("life", function(value, element) { // create "life" validator method return this.optional(element) || /^\d+|-1$/.test(value); }); var sam_1_dual_table = $("#sample-tabs-sam-1-dual-table").cms_dual_table({ // create cms_dual_table object editable:[ { type: [0], target: [3] }, // type 0 - source elFinder file manager, target 2 (id) set editable { type: [0], // type 0 - source elFinder file manager target: [6], // target 6 (life) set editable onsubmit: function(settings, td){ // jeditable plugin onsubmit callback function var input = $(td).find('input')[0]; // get jeditable input input.name = "nameofinput"; // set jeditable input name="nameofinput" $(this).validate({ // validate form rules: { 'nameofinput': { // jeditable input "life": true // check with "life" validator method } }, messages: { 'nameofinput': { // // jeditable input "life": "Please enter valid cache lifetime number" // message if error } } }); return ($(this).valid()); // return validation result } }, { type: [0], // type 0 - source elFinder file manager target: [5], // target 5(caching) set editable data: { type:"select", // set input type select data: {'':'','caching':'caching','nocache':'nocache','inline':'inline', 'selected': ''} // set select options list } } ] }); var t = [ // left side table initialization data array ["0","sample1","sample_1.file","caching","3600"], // 1-st row: type, id, file, cache life ["0","sample2","sample_2.file","nocache",""] //2-cnd row: type, id, file, cache life ]; sam_1_dual_table.cms_dual_table("add",t); // load data into left side table $(".sample-tabs-sam-1-dual-table-save", sam_1_dual_table).click(function(){ // on click button "Save" var t = sam_1_dual_table.cms_dual_table("getData"); // get data array from target dataTable() object alert("Save JSON data: " + JSON.stringify(t)); // convert to JSON and alert data array }); $(".sample-tabs-sam-1-dual-table-clear", sam_1_dual_table).click(function(){ // on click button "Clear" sam_1_dual_table.cms_dual_table("clear"); // clear target dataTable() object });

HTML code snippet:

<div id="sample-tabs-sam-1-dual-table"> <table class="sample-jquery-dual-table" style="width:100%"> <tr class="sample-jquery-dual-table-table"> <td> <div class="cms_docs_title">Files list</div> <table cellpadding="0" cellspacing="0" border="0" width="100%" class="cms-doc-files cms-dual-table-selected display"> <thead> <tr> <th></th> <th style="vertical-align:bottom">No</th> <th style="vertical-align:bottom"></th> <th style="vertical-align:bottom">ID<sup>1</sup></th> <th style="vertical-align:bottom">File</th> <th style="vertical-align:bottom">Cache<sup>2</sup></th> <th style="vertical-align:bottom">Life<sup>3</sup></th> </tr> </thead> </table> <p style="font-size:10px; font-weight:bold; font-style:italic; margin:0px; margin-top:10px">Note 1: Click to enter ID</p> <p style="font-size:10px; font-weight:bold; font-style:italic; margin:0px">Note 2: Click to enter Cache: "caching", "nocache", "inline"</p> <p style="font-size:10px; font-weight:bold; font-style:italic; margin:0px">Note 3: Click to enter Life (-1 means unlimited cache life time)</p> <p style="font-size:10px; font-weight:bold; font-style:italic; margin:0px">Note 4: Drag and drop to change file order</p> <input type="button" class="sample-tabs-sam-1-dual-table-save cms-form-submit" style="margin-top:10px" value="Save" title='Save'> <input type="button" class="sample-tabs-sam-1-dual-table-clear cms-form-submit" style="margin-top:10px" value="Clear" title='Clear'> </td> </tr> <tr class="sample-jquery-dual-table-buttons"> <td> <table> <tr><td><div class="cms-selectbox-button-add"><a href="#cms-dual-table-button-add" title="Add"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-rem"><a href="#cms-dual-table-button-rem" title="Remove"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-add-all"><a href="#cms-dual-table-button-add-all" title="Add all"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-rem-all"><a href="#cms-dual-table-button-rem-all" title="Remove all"></a></div></td></tr> </table> </td> </tr> <tr class="sample-jquery-dual-table-elfinder"> <td><div class="cms-dual-table-elfinder"></div></td> </tr> </table> </div>

Sample 3:

  • Left side table "ID" cell editable (<input>)
  • Left side table "Data list file path" cell editable (<input>)
  • Left side table rows draggable
  • Right side source: form fields inputs
  • Only unique combination of concatenate cells "ID", "Label" and "Datalist file path" can be added to left side list table
  • Button "Save" show left side table content in JSON format
  • Button "Clear" delete all rows from left side table
  • Buttons in the middle: add, remove, add all, remove all

jQuery code snippet:

var validateEmpty = function(settings, td){ // validate empty on left side table cell editing var input = $(td).find('input')[0]; // editable input input.name = "nameofinput"; // editable input name $(this).validate({ // form validate rules: { 'nameofinput': { // input name "required": true // check if not empty } }, messages: { 'nameofinput': { // error message for input name "required": "Please enter data" // error message } } }); return $(this).valid(); // return validation results } var sam_3_dual_table = $("#sample-tabs-sam-3-dual-table").cms_dual_table({ // create cms_dual_table object editable:[{type: [1], target: [3,4,5], onsubmit: validateEmpty}], // type: 1 - external (form fields in this case) // target: 3,4,5 - copy form fields into target row positions // onsubmit: validateEmpty - execute validation function validateEmpty on jeditable input submit copy: [ {type: [1], src: "item", from: 3, to: 3, length: 3, unique: 1} // type: 1 - external (form fields in this case) // src: "item" - source is right side form inputs // to: 3 - copy form fields from right to left side table starting with 3-rd position of left side table row // unique: 1 - only unique data (concatenate all fields when checking) can be copied // check: 0 - do not check data on right side form are valid URL (suitable when there are form fields) ] }); var t = [ // left side table initialization data array ["1","id1","label1","file.path1"], // 1-st row: type, id, label, file ["1","id2","label2","file.path2"] //2-cnd row: type, id, label, file ]; sam_3_dual_table.cms_dual_table("add", t, "id"); // load data into left side table ("id" - means insert ID instead of type name = tab id $(".sample-tabs-sam-3-dual-table-save", sam_3_dual_table).click(function(){ // on click button "Save" var t = sam_3_dual_table.cms_dual_table("getData"); // get data array from target dataTable() object alert("Save JSON data: " + JSON.stringify(t)); // convert to JSON and alert data array }); $(".sample-tabs-sam-3-dual-table-clear", sam_3_dual_table).click(function(){ // on click button "Clear" sam_3_dual_table.cms_dual_table("clear"); // clear target dataTable() object });

HTML code snippet:

<div id="sample-tabs-sam-3-dual-table"> <table class="sample-jquery-dual-table" style="width:100%"> <tr class="sample-jquery-dual-table-table"> <td> <div class="cms_docs_title">Files list</div> <table cellpadding="0" cellspacing="0" border="0" width="100%" class="cms-doc-files cms-dual-table-selected display"> <thead> <tr> <th></th> <th style="vertical-align:bottom">No</th> <th style="vertical-align:bottom"></th> <th style="vertical-align:bottom">ID<sup>1</sup></th> <th style="vertical-align:bottom">Label</th> <th style="vertical-align:bottom">Data list file path<sup>2</sup></th> </tr> </thead> </table> <p style="font-size:10px; font-weight:bold; font-style:italic; margin-bottom:0px">Note 1: Click to edit list ID</p> <p style="font-size:10px; font-weight:bold; font-style:italic; margin-top:0px; margin-bottom:0px">Note 2: Click to edit data list file path</p> <p style="font-size:10px; font-weight:bold; font-style:italic; margin-top:0px">Note 3: Drag and drop to change list order</p> <input type="button" class="sample-tabs-sam-3-dual-table-save cms-form-submit" style="margin-top:10px" value="Save" title='Save'> <input type="button" class="sample-tabs-sam-3-dual-table-clear cms-form-submit" style="margin-top:10px" value="Clear" title='Clear'> </td> </tr> <tr class="sample-jquery-dual-table-buttons"> <td> <table> <tr><td><div class="cms-selectbox-button-add"><a href="#cms-dual-table-button-add" title="Add"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-rem"><a href="#cms-dual-table-button-rem" title="Remove"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-add-all"><a href="#cms-dual-table-button-add-all" title="Add all"></a></div></td></tr> <tr><td><div class="cms-selectbox-button-rem-all"><a href="#cms-dual-table-button-rem-all" title="Remove all"></a></div></td></tr> </table> </td> </tr> <tr class="sample-jquery-dual-table-elfinder"> <td> <div class="cms-dual-table-tabs"> <ul> <li><a href="#cms-dual-table-ext" title='Enter file id, label and path'>Enter file data</a></li> </ul> <div class="cms-dual-table-ext"> <div style="white-space:nowrap"> <table> <tr> <td class="cms-form-td">ID: </td> <td class="cms-form-td"><input class="cms-dual-table-input cms-form-input" type="text" style="width:150px" value="" title='Enter file ID'></td> </tr> <tr> <td class="cms-form-td">Label: </td> <td class="cms-form-td"><input class="cms-dual-table-input cms-form-input" type="text" style="width:150px" value="" title='Enter label'></td> </tr> <tr> <td class="cms-form-td">Path: </td> <td class="cms-form-td"><input class="cms-dual-table-input cms-form-input" type="text" style="width:150px" value="" title='Enter file path'></td> </tr> </table> </div> </div> </div> </td> </tr> </table> </div>