Options from Ajax

As of SearchPanes 1.2.0 it is possible to load the initial options into SearchPanes using ajax. This will mean that the load times for SearchPanes will be much faster, this is because it doesn't have to process the data in the table to create the options. Once the options are loaded into SearchPanes all of the processing is done on the client side, you can of course change this by using Server-Side Processing.

The structure of the JSON data that is required is exactly the same as when Server-Side processing is in use. The following structure must be included within the ajax response.

Parameter name Type Description
searchPanes.options[field][i] array This array contains all of the data necessary for a record in a SearchPane of a given field.
searchPanes.options[field][i].label string This is the value that is to be displayed to the user in the SearchPane option.
searchPanes.options[field][i].value string This is the value that is to be used for filtering, sorting and searching in the SearchPane option.
searchPanes.options[field][i].total int This is the total number of entries in the given field of this value.
searchPanes.options[field][i].count int This is the count of entries in the given field that match the current where condition.

An example of how a return looks using these options is shown below.

"searchPanes":{
    "options":{
        "users.first_name":[
            {
               "label":"Aaron",
               "total":"1",
               "value":"Aaron",
               "count":"1"
            },
            {
               "label":"Alex",
               "total":"1",
               "value":"Alex",
               "count":0
            },
            {
               "label":"Alexa",
               "total":"1",
               "value":"Alexa",
               "count":0
            },
            ...
        ]
    }
},
...

It is worth noting that searchPanes.cascadePanes and searchPanes.viewTotal are not supported when using this option. While it is still possible to enable these options, it is not advised and may lead to unexpected behaviour. This is because it is vital that the user provides accurate data for the pane options.

A full working example can be found here