javascript - How to provide data to Fuel UX datagrid from Rails? -
javascript - How to provide data to Fuel UX datagrid from Rails? -
i'd utilize fuel ux datagrid display info retrieving database. page served ruby on rails server.
the javascript illustration code building info object:
var datasource = new staticdatasource({ columns: [{ property: 'toponymname', label: 'name', sortable: true }, { property: 'countrycode', label: 'country', sortable: true }, { property: 'population', label: 'population', sortable: true }, { property: 'fcodename', label: 'type', sortable: true }], data: sampledata.geonames, delay: 250 }); $('#mygrid').datagrid({ datasource: datasource, stretchheight: true }); $('#datagrid-reload').on('click', function () { $('#mygrid').datagrid('reload'); });
if understanding code, going defining columns , attributes in columns object within of datasource variable, , info object beingness loaded sampledata.geonames.
the sampledata here
what can using rails conventions replace sampledata.geonames? tried tweaking few ways load rails objects in here.
for example, modified columns' property fields correspond properties of user model. tried replacing the
data: sampledata.geonames,
to
data: <%= @users.to_json %>,
i'm little restricted on gems , versions, using rails 2.3.
thanks help.
if want datagrid create background ajax request load info app, please see tutorial closer need:
http://dailyjs.com/2012/10/29/fuel-ux
this have benefit of immediate page load followed asynchronous loading of data.
if rather stick staticdatasource approach embed little script on page similar this:
<script> var mydata = { ... }; </script>
then, load with:
var datasource = new staticdatasource({ columns: [ ... ], data: mydata, delay: 250 });
javascript ruby-on-rails fuelux
Comments
Post a Comment