0

I spent all weekend trying to make this work, and couldn't figure it out.

How do I create a views exposed filter for date and a text list on a given node?

My setup - I have a view that is exposed as JSON with a task_name field, a date field, and a status field.

I have the date module installed in both Drupalgap as well as Drupal, and I'm able to get that to display correctly.

I've tried creating a select list for day, month and a year, as well as task status, and this seems clunky (four select lists takes up quite a bit of room - and I can't figure out how to collapse them - perhaps some sort of "collapse format"?)

But even if I do create them, there seems to be no way to have an interaction between them and the view content object. I tried grabbing the values of the select lists from the path of the views object, but there seems to be no way to do that.

My views code looks like this, almost an exact copy of the beer example:

function task_list_page() {
  try {
    var content = {};
    content['task-list'] = {
      theme: 'view',
      format: 'ul',
      path: 'tasks.json',
      row_callback: 'task_list_page_row',
      empty_callback: 'task_list_page_empty'
    };
    return content;
  }
  catch (error) { console.log('task_list_page - ' + error); }
}

What would I do to this to create an exposed filter for date and status, both of which are columns in the view? How would I make this filter compact and perhaps collapsible?

  • According to the docs here drupalgap.org/node/498 the filter should be added to your app when you create it in your view and then publish it. – jowan sebastian Nov 7 '14 at 21:20
  • Ha, that was posted since the time period that I asked the question. Let me check that out and test it. – Jack Ryan Nov 7 '14 at 22:40
0
+50

According to the docs here drupalgap.org/node/498 the filter should be added to your app when you create it in your view and then publish it. If those instructions do not work to create a simple filter, I suggest raising and issue over there.

As to Date filtering, I expect that only the select list exposed form items will transfer to your app out-of-the-box. If you want some custom UI elements such as jQuery mobile date picker to match the rest of your app UI, you will have to use a text field in the views exposed filter then edit the code on you app to call the UI element.

A lot of the time with similar things, I end up creating icon links in the header that act like filters and sorters e.g.

<?php
print l("<i class='icon icon-cancel-circled'></i>", "my/view", array('html' => TRUE, 'query' => array('sort_by' => 'created', 'sort_order' => 'ASC')));
?>

This makes an arrow up icon link (if you're implementing icons somehow) which will go to the view sorted by "created" "ascending".

Having an exposed filters form in an app is often too much for a small screen when a few icons will do, and this should transfer to your app in the header ok.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.