Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make YUI datasource parse Null values in the dataset?
    primarykey
    data
    text
    <p>I am using YUI datatable and datasource to render data in one of my projects. The data returned happens to be NULL and YUI datasource is unable to parse it.</p> <p>Below is the declaration code of datasource and datatable. For readability sake, I am seperating each of the declarations.</p> <p><strong>Column Descriptions declaration</strong></p> <pre><code> var columnDescription = [ {key:'Requirements'}, {key:'abc'}, {key:'xyz'} ]; </code></pre> <p>This columnDescription is set in the function below.</p> <p><strong>DataSource Declaration</strong></p> <pre><code> var dataSrcSample = new YAHOO.util.FunctionDataSource(getDataGrid); myDataSource.connMethodPost = true; myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; myDataSource.responseSchema = { fields:['Requirements', {key:'abc',parser:YAHOO.util.DataSource.parseString}, {key:'xyz',parser:YAHOO.util.DataSource.parseString}] }; </code></pre> <p><strong>getDataGrid</strong> function makes the call to server side to get the data from the server. Below is the table definition itself.</p> <pre><code> YAHOO.example.sampleTable = function() { var columnDesc=columnDescription; var myDataSource = dataSrcSample; var oConfigs = { width:'100%' }; var myDataTable = new YAHOO.widget.DataTable("tableContainerDiv", columnDesc, myDataSource, oConfigs); }(); </code></pre> <p><strong>tableContainerDiv</strong> is declared in the html page. This is the container div. The function that gets the JSON data from server.</p> <pre><code>function getDataGrid() { //calls backend and gets the data } </code></pre> <p>The function is returning json string that has some null values. Datasource constructor is complaining following problems.</p> <ul> <li>ERROR_DATAINVALID</li> <li>ERROR_DATANULL</li> </ul> <p>I checked the yui <a href="http://developer.yahoo.com/yui/docs/YAHOO.util.DataSourceBase.html#method_DataSourceBase.parseString" rel="nofollow noreferrer">documentation</a> and found that the string parser does not parse null values. I am wondering if there is any way to parse this data. Do I have to handleResponse parse the raw data? Any suggestions appreciated.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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