You are here

function slickgrid_encode_columns in Slickgrid 7.2

Same name and namespace in other branches
  1. 7 slickgrid.module \slickgrid_encode_columns()

Encode the columns as a json array We can't simply use drupal_json_encode as the column definitions contain function names

Parameters

array $columns:

1 call to slickgrid_encode_columns()
theme_slickgrid in theme/theme.inc
The main theme function for the slickgrid

File

theme/theme.inc, line 546

Code

function slickgrid_encode_columns($columns) {
  $encoded_columns = drupal_json_encode($columns);
  foreach (slickgrid_get_plugin_types() as $type => $plugin) {
    $encoded_columns = preg_replace('/("' . $type . '":)"([a-z]*)"/i', '$1$2', $encoded_columns);
  }

  // Width need to be parsed an integers, so remove the "s
  $encoded_columns = preg_replace('/("width":)"([0-9]*)"/i', '$1$2', $encoded_columns);
  return $encoded_columns;
}