PageBlockTableEnhancerADV : Yes we have the export now!

A bit of Introduction 


PageBlockTableEnhancerADV is a plugin that lets you convert a normal VisualForce pageblock table into a datatable. The component internally uses the Datatables plugin to bring in features like sorting, filtering and pagination.



So what's new ?


So as planned this post is all about File Exports!, Yes files export is being ported from Datatables to PageBlockTableEnhancerADV. To export files PageBlockTableEnhancerADV uses the Datatable plugin TableTools. TableTools is very flexible plugin that hooks in to the Datatables API to give in an amazing set of exporting option.

So this version of PageBlockTableEnhancerADV with the help of TableTools brings in 
  • Export to PDF
  • Export to CSV
  • Export to Excel
  • Printable view
  • Copy to clipboard
If you are not aware about the PageBlockTableEnhancerADV or PageBlockTableEnhancer you can read about the same from the below links

List of Parameters 


  • targetPbTableIds : comma-separated Ids of the target Pageblock tables 
  • paginate : Assign true if you want to use the pagination feature,default value is true.
  • pageSizeOptions : A comma separated list of integer values that will displayed as dropdown for page size
  •  defaultPageSize : Default page size that needs to be selected (at page load).
  • enableExport : Set this option to true to enable export toolbar (new in v2)
  • exportFileName : Default filename to use when a user uses the export feature. (new in v2)

Syntax


<c:PageBlockTableEnhancerADV targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100" enableExport="true" exportFileName="myFile"/> 



25 comments:

  1. component is not working when sidebar is true and currency fields are not sorting.could you please look into it.I have installed from the above link in my dev org

    ReplyDelete
    Replies
    1. You probably have something in your sidebar, may be a jquery component, this works with sidebar on. I am looking into the currency sorting stuff

      Delete
    2. I just installed it and it is not working in IE 8.

      Delete
    3. I had a similar issue where I could not get the component to render consistently. I had been using it on both inline VF pages and full pages previously, but added it to a new page and it would not show up. Turns out that on my "full" VF pages with sidebar showing, I had another jQuery component interfering with the pageBlockTableEnhancer. I have not had time to modify any code but hiding the sidebar for these pages (and thus not calling any other jQuery components) worked for now.

      Delete
    4. I just installed and I'm experiencing a similar issue. When the sidebar is true it doesn't work. If sidebar is false it works well. This is true for both Chrome and Firefox, the only two I've checked so far.

      Delete
  2. I am having an issue with sorting a DateTime column. The PageBlockTable does not sort if the Dates are all the same. (It appears to ignore the Time portion of the DateTime.) If the dates are different, however, the sorting seems to work. Has anyone experienced this? Is there a fix for it?

    ReplyDelete
    Replies
    1. Which version you are using ? I will try to replicate the same and will let you know.

      Delete
  3. Very nice work. I found an issue with multiple tables for the export functionality. With more than one table the buttons do not work. It turns out that you can't do a mass initialization using $('Blog9ectc').datatable([parameters....}) but need to loop through and do them individually. It was easy to fix, I just added a counter and named each table by a different class name (classname + counter) and then looped through the tables and did a initialization or each on.. http://datatables.net/forums/discussion/3963/tabletools-on-multiple-tables/p1

    I added a counter in two places and had it create a class for each table
    Then did the intitialization in a foreach.

    var targetIds = '{!targetPbTableIds}';
    var targetIdArray = targetIds.split(",");
    var i=0;// here is the counter
    $(targetIdArray ).each(function(){
    i=i+1;// here is the counter
    var elem = this.trim();
    var elemObj = $("[id$='"+elem+"']");
    elemObj.addClass("BlogForce9TableADV"+i);//*each table got classed differently
    });
    i=0;
    $(targetIdArray ).each(function(){
    i=i+1;//here again
    dataTable = $('.BlogForce9TableADV' + i).dataTable({ //Loop through
    "bJQueryUI": true,
    .....});

    Thanks for all the great tools - hope this is usefull

    ReplyDelete
    Replies
    1. Thanks nice catch!
      I will be looking into and fixing it as soon as possible.

      Delete
    2. Quick Q : for whatever reason I get only 20 records displayed when there are many more than that. Pagination is on .

      Delete
  4. I am having an issue using the component and calling pageReference methods. In my instance, I am performing a custom search (to reduce the # of records returned) of Pricebook Entries, rendering a custom object instance of Pricebook Entry and some variables, then displaying them in a pageBlockTable. If the row is "Selected" (bheckbox), the commandButton calls a pageReference method, saving the records as QLI's. However, whenever the table is rendered using the component, the page simply refreshes with the pageRef methods not being called. If I hide the component, the pageRef method works fine. The pageRef saves the records and then redirects to another page.

    Any thoughts on what might be causing this?

    ReplyDelete
    Replies
    1. I haven't seen a issue like this, I will try the same in my org and will let you know

      Delete
    2. I have actually found this same issue on many actions, but seems inconsistent. I have tried save different variations of the page, but the only way to consistently execute the methods are by removing the component. I will keep working on it, as I really like this component and it's functionality is really what I want/need to finish off this process I'm working on. Please let know if I can provide any code samples that may help. Thanks.

      Delete
    3. This comment has been removed by the author.

      Delete
    4. You won't believe it! In my table, I had input fields to allow the user to specify quantity, sales price, etc. The pageBlockTable had originally been pulling in records from a custom class and I was using inputText for those fields. I then rebuilt it using custom fields on an actual custom OBJECT, had encountered the same issues but just continued to use the custom object to populate the table. After much troubleshooting, I flipped to inputFIELD as a last ditch effort and it worked! It shouldn't of made a difference, but it allowed me to finish up my page in just a few additional minutes. Quirky but I'm glad that it seems to be working! Thanks again for the wonderful VF component!!

      Delete
    5. Thanks for the feedback, I will keep a note of this.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Hi Avinava,

    I am using PageBlockTableEnhancerADV on my VF page. I do not want to display search box on pageblock header. Could you please suggest how I can remove or hide this?

    Hope to see your response soon ! :)

    - Pragya Tiwari

    ReplyDelete
  7. I think you can add style something like .dataTables_filter{display:none}

    ReplyDelete
  8. Avinava, this tool is great, exactly the functionality I was hunting for. Quick request, would it be possible to add a "New" button, to add a record into the data table? Thanks for your consideration.

    ReplyDelete
  9. How to prevent sorting for a particular column?

    ReplyDelete
  10. Excellent work just one problem, it has sorting issues. It sorts by one or two colums in a Vf page. First we seem to think that sorting is fine but when we use it carefully it has problems with sorting. If we have 10 column it will sort them all but on basis of any two random colum in those 10 column.

    ReplyDelete
  11. Great plugin, Helps alot.
    One thing i would like to share that is in Lightning Interface if you have more than 7,8 columns then the theme if this plugin works on first 6,7 columns. It works till there is search bar visible. After that the remaining columns work but they dont have the grey theme and bars aaround them.

    ReplyDelete
  12. Hi this is a great plugin but can it paginate records beyond the limit of vf pages which is 1000?

    ReplyDelete
  13. Hi,

    Why does it restrict to show only 10 records even if we use a custom pagination and not standard setController. ?

    ReplyDelete