Summary Row in List? Or easy way to copy list data?

Status
Not open for further replies.

nbradshaw

Active Member
My users need a way to easily copy the date in the rows from a list---just from one column.

Is there a way to summarize all the rows in the group dropdown? Or create another column with a group_concat for all rows with the same "batch id"?

Example (from attachment):
Users would want to copy like this from the list group (without the need to export to csv first):
AL500402
AL500401
AL500400
AZ500399
CO500398
IN500397


Any other thoughts?
 

Attachments

  • Capture.JPG
    Capture.JPG
    116.4 KB · Views: 38
It might be possible to do in a very hacky way with a JS list plugin, basing your code on this, which I stole and modified from here:

http://jsfiddle.net/styson/tJcQN/

JavaScript:
function resetColumnSelection() {
    jQuery(".temp, .text").remove();
    jQuery(".highlight").removeClass("highlight");
}

jQuery("th.fabrik_ordercell").dblclick(function() {
   resetColumnSelection();
   var colData = "";

   var th = jQuery(this);
   var colIndex = th.index();
   jQuery(th).parents("table").find("tbody tr:visible").each(function() {
      var $columnCell = jQuery(this).children("td:eq(" + colIndex + ")");
      colText = jQuery.trim($columnCell.text());
      $columnCell.addClass("highlight");
      if(colText > "") colData += ((colData > "")? ", " : "") + colText;
   });

   jQuery("<span class='text'>Text from Selected Column:</span>" + 
     "<input type='text' class='temp' />")
       .val(colData)
       .insertAfter(th.parents("table"))
       .focus()
       .select();
  
   document.execCommand('copy');
});

That creates a text input on the fly after the table, with the column data in it, selects the text, and copies it to the copy buffer.

That would go in a ./components/com_fabrik/js/list_X.js file, where X is your numeric list ID.

If you also added a custom CSS to your template, with something like:

.highlight { background-color: #ffff80; }

... it should hilite the select data.

NOTE - this will select all opened groups (visible rows).

-- hugh
 
Just FYI, if you need more assistance on this, I'll need to charge it as custom work. Getting that far took me almost an hour. I wouldn't usually spend that long on custom coding questions as part of subscription support, but it was interesting, and something I've wanted to figure out how to do for a while.

If you need newlines rather than commas, you'll probably need to tweak it to use a textarea rather than a simple input=text field for the temporary container.

-- hugh
 
Very Awesome Hugh! Yes, this was my pie in the sky solution that I was wishing for...but didn't expect...so thanks!!!

First time using a List JS Plugin...I have put the code you provided here: ./components/com_fabrik/js/list_149.js

What do I put into the List JS Plugin?
 
ok... I missed clicking the header part...it's freaken awesome!!!...thanks Hugh!!! BTW - if this could be turned into a list plugin - I'm sure the community could use it.
 
Also - I tried to modify the js to use a textarea...but no luck. I emailed the JS Fiddle code contributor to see if he had some ideas.
 
Ok..the contributor was extremely helpful...

Here is the js code to use a text area, separated by line break:

js fiddle: http://jsfiddle.net/styson/d50x19bv/1/

JavaScript:
function resetColumnSelection() {
    jQuery(".temp, .text").remove();
    jQuery(".highlight").removeClass("highlight");
}

jQuery("th.fabrik_ordercell").dblclick(function() {
   resetColumnSelection();
   var colData = "";

   var th = jQuery(this);
   var colIndex = th.index();
   jQuery(th).parents("table").find("tbody tr:visible").each(function() {
      var $columnCell = jQuery(this).children("td:eq(" + colIndex + ")");
      colText = jQuery.trim($columnCell.text());
      $columnCell.addClass("highlight");
      if(colText > "") colData += ((colData > "")? "\r\n" : "") + colText;
   });

   jQuery("<span class='text'>Text from Selected Column:</span>" +
     "<textarea class='temp' rows=4 />")
       .val(colData)
       .insertAfter(th.parents("table"))
       .focus()
       .select();
 
   document.execCommand('copy');
});
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top