Skip to content

Problem with custom query parameter #73

@jasonl99

Description

@jasonl99

I have a set up where I allow the user to search by multiple tags, plus use the default text search provided by selectize. When both are filled out, it works great. here's the json sent to the server:

{
       "queries" => {
         "search" => "test"
          "order_type" => [
            [0] "retail"
            ]
  },
        "page" => "1",
     "perPage" => "10",
      "offset" => "0",
      "action" => "index",
  "controller" => "admin/entities",
      "format" => "json"
}

Note the "order_type" array of tags.

However, if the user uses only the tag function, and leaves the search blank, the 'processing' indicator does not go away (though the data loads fine). Here's what the json looks like sent to the server:

{
       "queries" => {
          "order_type" => [
            [0] "retail"
            ]
  },
        "page" => "1",
     "perPage" => "10",
      "offset" => "0",
      "action" => "index",
  "controller" => "admin/entities",
      "format" => "json"
}

Note that there is no 'search' query. Selectize is having a problem with this in this area of code:

   // For queries, we're going to handle each possible query parameter individually here instead of
          // handling the entire queries object below, since we need to make sure that this is a query controlled by dynatable.
          if (attr == "queries" && data[label]) {
            var queries = settings.inputs.queries || [],
                inputQueries = $.makeArray(queries.map(function() { return $(this).attr('name') }));

            if (settings.features.search) { inputQueries.push('search'); }

            for (var i = 0, len = inputQueries.length; i < len; i++) {
              var attr = inputQueries[i];
              if (data[label][attr]) {
                if (typeof urlOptions[label] === 'undefined') { urlOptions[label] = {}; }
                urlOptions[label][attr] = data[label][attr];
              } else {
                delete urlOptions[label][attr];
              }
            }
            continue;
          }

The delete UrlOptions[label][attr] has an issue because there is not a search attribute in the json sent to the server in this circumstance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions