Hi, I am using a DataView inside a Form like this:
function Init()
{
initializeProductsForm();
initializeCategoryDataView();
}
function initializeProductsForm()
{
var formData = [
{
type: "settings",
position: "label-left",
inputWidth: 220
},
{
type: "template",
name: "related",
format: "doRelated",
label: 'Related Products',
position: 'label-top',
labelAlign: 'center',
offsetTop: 20
}
];
myForm1 = new dhtmlXForm("formContainer", formData);
}
function initializeCategoryDataView()
{
view = new dhtmlXDataView({
container: 'related',
type: {
template: "<div align='center'><img onmousedown='return false;' width='24' height='24' border='0' src='{common.image()}'><div class='dhx_item_text'>#text#</div></div>",
css: 'ficon',
width: 30,
height: 30,
image: function (obj)
{
return "../modules/views/dhtmlxTree/sources/imgs/ok/" + obj.icon;
}
},
drag: true,
select: true,
height: 400,
icon: 'product.png',
text: 'New'
});
attachProductsDataViewEvents();
view.add({
text: 'New Prod',
image: 'product.png'
});
}
function doRelated(name, value)
{
return "<div id='related'></div>";
}
but the ‘New Prod’ item doesn’t show up until I drop another item into the DataView container.
I have already debugged the project, but found nothing else but this awful solution.
setTimeout(function ()
{
view.add(
{
text: 'New Prod',
image: 'product.png'
});
}, 6000);
P.S. It only works if time is greater than 5000
Before calling initializeCategoryDataView(); the HTML contains this:
which is the expected behavior.
Before calling view.add(…);
which is the expected behavior.
Please help me to find my mistake