Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know you have already solved the problem but I faced the same problem in my project and would like to offer my solution.</p> <p>First, I declare a custom formatter for my select column (in this case, the 'username' column).</p> <pre><code>$.extend($.fn.fmatter, { selectuser: function(cellvalue, options, rowdata) { var userdata; $.ajax({ url:'dropdowns/json/user', async:false, dataType:'json', cache:true, success: function(data) { userdata = data; } }); return typeof cellvalue != 'undefined' ? userdata[cellvalue] : cellvalue ; } }); </code></pre> <p>This formatter loads up the mapping of id and user in this case, and returns the username for the particular cellvalue. Then, I set the <code>formatter:'selectuser'</code> option to the column's <code>colModel</code>, and it works.</p> <p>Of course, this does one json request per row displayed in the grid. I solved this problem by setting 10 seconds of <a href="http://www.electrictoolbox.com/php-caching-headers/" rel="nofollow">caching</a> to the headers of my json responses, like so:</p> <pre><code>private function set_caching($seconds_to_cache = 10) { $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT"; header("Expires: $ts"); header("Pragma: cache"); header("Cache-Control: max-age=$seconds_to_cache"); } </code></pre> <p>I know this solution is not perfect, but it was adequate for my application. Cache hits are served by the browser instantly and the grid flows smoothly. Ultimately, I hope the built-in <code>select</code> formatter will be fixed to work with json data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload