EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jpierce on June 06, 2013, 10:38:36 AM



Title: getting raw data from datagrid
Post by: jpierce on June 06, 2013, 10:38:36 AM
Is there no way to avoid having all your datagrid data mashed down into Strings?  When my datagrid loads JSON data, it's in String, Number, boolean, null, etc.  But as far as I can tell, datagrid just treats that all as text.  Is there any way around this other than having my application know exactly what type of data each column should have in advance?


Title: Re: getting raw data from datagrid
Post by: stworthy on June 06, 2013, 11:29:49 PM
Some additional informations can be added in the column definition.
Code:
$('#dg').datagrid({
  columns:[[
    {field:'name',width:100,datatype:'string'},
    {field:'salary',width:100,datatype:'number',align:'right'}
  ]]
});

Calling 'getColumnOption' method and the user will be able to get the specified field option.
Code:
var col = $('#dg').datagrid('getColumnOption','name');  // the 'name' field option
alert(col.datatype);  // the 'datatype' property


Title: Re: getting raw data from datagrid
Post by: jpierce on June 11, 2013, 07:40:58 PM
Thanks.  I may have to create some system to extract the metadata from the table.  Unfortunate that it can't just preserve the original datatype but I guess I could see why.


Title: Re: getting raw data from datagrid
Post by: jpierce on June 14, 2013, 08:34:41 AM
Any chance of getting this added to the data-options you can set on the TH elements?  Would be a lot easier to code that way in my situation.


Title: Re: getting raw data from datagrid
Post by: jpierce on June 14, 2013, 08:48:50 AM
Wait, so does "datatype" not actually DO anything other than for ornamental purposes?  It seems that way to me.  I was really hoping for something the grid actually understood and would cause it to store the data as that type rather than string.