PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Sorting Column Limits Results to 12 not 20 Per Page

  1. kcreative
    Member

    I am using WP 3.4 and GF 1.6.4.5.4

    Under the entries view, when I sort a certain column the displayed results are only showing 12 entries per page instead of 20. I say a "certain column" as it doesn't matter the position in the display (1st, 2nd, 3rd column etc.) it still shows 12 results when sorted. The column field is a Single Line Text field, nothing special.

    The pagination shows "Displaying 1-20 of 108" along with the correct number of pagination links (6) for 108 entries, accounting for 20 results per page. The problem is the displayed results only actually give me 12 results per page resulting in 72 viewable entries. When I sort on any other column, I get 20 results per page.

    Any ideas how can this be fixed?

    Posted 12 years ago on Tuesday June 19, 2012 | Permalink
  2. David Peralty

    I am not sure why one specific column would mess things up when sorted. I will pass this on to the developers to see if it can be replicated. Can I have you run through the normal troubleshooting steps to see if it still occurs, and can you send a form export to peralty@rocketgenius.com ?

    http://www.gravityhelp.com/documentation/page/Testing_for_a_Theme/Plugin_Conflict

    Posted 12 years ago on Tuesday June 19, 2012 | Permalink
  3. kcreative
    Member

    This is a live site, so I am unable to change themes at this time. I am only using three plugins including GF. I turned off both of them and the problem persisted. Since the contents of the form are private, I can not send you an export. I can tell you the field consists of first, middle, and last names.

    Posted 12 years ago on Tuesday June 19, 2012 | Permalink
  4. kcreative
    Member

    Any luck on a possible cause?

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  5. David Peralty

    I've given you all the help I can flying blind. If you are unable to work through our troubleshooting steps, it is hard for me to figure out the source.

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  6. kcreative
    Member

    I have been debugging through the php and found something interesting that I can't explain. In forms_model.php, I've echoed out the generated SQL when sorting by the problem field:
    SELECT filtered.sort, l.*, d.field_number, d.value FROM wp_rg_lead l INNER JOIN wp_rg_lead_detail d ON d.lead_id = l.id INNER JOIN ( SELECT distinct sorted.sort, l.id FROM wp_rg_lead l INNER JOIN wp_rg_lead_detail d ON d.lead_id = l.id INNER JOIN ( SELECT @rownum:=@rownum+1 as sort, id FROM ( SELECT 0 as query, lead_id as id, value FROM wp_rg_lead_detail WHERE form_id=1 AND field_number between 0.999 AND 1.001 UNION ALL SELECT 1 as query, l.id, d.value FROM wp_rg_lead l LEFT OUTER JOIN wp_rg_lead_detail d ON d.lead_id = l.id AND field_number between 0.999 AND 1.001 WHERE l.form_id=1 AND d.lead_id IS NULL ) sorted1 ORDER BY query, value ASC ) sorted ON d.lead_id = sorted.id WHERE status='active' LIMIT 0,20 ) filtered ON filtered.id = l.id ORDER BY filtered.sort

    I then compared the results running the query via PHPMyAdmin and $wpdb->get_results($sql). The num_rows is different! I get all 20 distinct id's via PHPMyAdmin and 1219 rows, but only get 1120 rows and 12 distinct id's when run through Wordpress's get_results function. Any idea why?

    Posted 12 years ago on Wednesday June 27, 2012 | Permalink
  7. That is interesting...
    I haven't run into anything like this before, but there is a lot going on inside the $wpdb->get_results() function that could potentially drop some results. What I would recommend is that you step into the the get_results() function and see exactly where the results get dropped. That way we may have a better idea why that is happening and possibly find a workaround for it.

    Posted 12 years ago on Wednesday June 27, 2012 | Permalink