Hi:
Recline grid view filter not working when imported csv file column name has spaces.
The example file Polling_Places_Madison.csv has a space in column "Aldermanic District"
When a filter is applied, the "Loading" message never disappears.
I traced the issue to the function _dkan_datastore_api_datastore_index()
In the variable $filters, the spaces need to be replaced with underscores.
My hack to solve the problem follows, just as a reference, because as you see, it is just an ugly hack.
--- /root/docroot-new/profiles/dkan/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module 2014-04-28 13:40:07.000000000 -0500
+++ /var/www/html/profiles/dkan/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module 2014-06-05 17:23:59.318552600 -0500
@@ -170,12 +170,27 @@
);
}
+function fixArrayKey(&$arr)
+{
+ //Function replaces space with underscore in keys from an array recursively
+ $arr=array_combine(array_map(function($str){return str_replace(" ","_",$str);},array_keys($arr)),array_values($arr));
+ foreach($arr as $key=>$val)
+ {
+ if(is_array($val)) fixArrayKey($arr[$key]);
+ }
+}
+
/**
* Creates index based off of query.
*
* For arguments, see: dkan_datastore_api_services_resources().
*/
function _dkan_datastore_api_datastore_index($resource_ids, $filters, $query, $offset, $limit, $fields, $sort, $join) {
+
+ if (is_array($filters)) {
+ fixArrayKey($filters);
+ }
+
try {
// Query for a single resource.
if (count($resource_ids) < 2) {
Hi: Recline grid view filter not working when imported csv file column name has spaces. The example file Polling_Places_Madison.csv has a space in column "Aldermanic District" When a filter is applied, the "Loading" message never disappears.
I traced the issue to the function _dkan_datastore_api_datastore_index() In the variable $filters, the spaces need to be replaced with underscores.
My hack to solve the problem follows, just as a reference, because as you see, it is just an ugly hack.