function drawTable(fields, rows)
{
var head = '
';
for(let field in fields)
{
var fieldName = fields[field];
fieldName = (typeof fieldSettings[field] !== 'undefined' && fieldSettings[field].name ? fieldSettings[field].name : fieldName);
var width = getTextWidth(fieldName) + 40;
head += '';
}
head += '
';
var html = '' + head + '';
var body = '';
for(let row of rows)
{
body += '';
for(let index in row) body += '| ' + row[index] + ' | ';
body += '
';
}
html += '' + body + '';
$('table.result').html(html);
}
function getTextWidth(text)
{
var font = "bold 12pt arial"
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
context.font = font;
var measure = context.measureText(text);
return measure.width;
}
function configHeader(obj)
{
modal = new $.zui.ModalTrigger({title: lang.fieldSettings, custom: function(el) {
var html = '';
return html;
}});
modal.show({onShow: function()
{
setTimeout(function() {
$('.chosen').chosen();
$('select[name^="object"]').change(function(e)
{
var object = $(this).val();
var objectid = $(this).attr('id');
var $that = $(this);
if(!object)
{
return false;
}
$.get(createLink('dataset', 'ajaxGetTypeOptions', 'object=' + object), function(res)
{
var index = objectid.substring(6);
var id = 'type' + index;
var res = JSON.parse(res);
var options = '';
for(let key in res.options)
{
options += '';
}
allTypeOptions[object] = res.options;
var html = '';
$that.closest('.td-row').find('.typebox').html(html);
$('.types').chosen();
});
});
}, 20)
return false;
}})
modal.show();
}