Skip to content

Instantly share code, notes, and snippets.

@goog
Created June 5, 2013 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goog/5711233 to your computer and use it in GitHub Desktop.
Save goog/5711233 to your computer and use it in GitHub Desktop.
custom my data table
var hosts_tab_content = '\
<div class="row">\
<div class="six columns">\
<table id="datatable_test" class="datatable six">\
<thead>\
<tr>\
<th>' + tr("ID") + '</th>\
<th>' + tr("Name") + '</th>\
<th>' + tr("Cluster") + '</th>\
<th>' + tr("RVMs") + '</th>\
<th>' + tr("Real CPU") + '</th>\
<th>' + tr("last col") + '</th>\
</tr>\
</thead>\
<tbody>\
</tbody>\
</table>';
var dataTable_hosts;
//Setup actions
var host_actions = {
"Mymy.list" : {
type: "custom",
call: function() {
$.getJSON("http://localhost:4567/json",
function(data){return data});
},
callback: updateHostsView,
error: onError
},
};
var hosts_tab = {
title: tr("Dummy2"),
content: hosts_tab_content,
};
Sunstone.addActions(host_actions);
Sunstone.addMainTab('dummy2-tab',hosts_tab);
//callback to update the list of hosts.
function updateHostsView (request,data){
var host_list_array = [];
// push the array to it
alert(data.ay);
host_list_array.push(data.ay);
alert(host_list_array);
updateView(host_list_array,dataTable_hosts);
}
$(document).ready(function(){
var tab_name = 'dummy2-tab';
//prepare host datatable
dataTable_hosts = $("#datatable_test",main_tabs_context).dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [5,6,7,8] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
Sunstone.runAction("Mymy.list");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment