如何刷新自定义控件? [英] How to refresh a custom control?
问题描述
我在html lightswitch项目中有几个嵌入式仪表板作为自定义控件.它们显示由用户从数据库中操纵的数据.我想在afterClosed:事件中设置对象的.refresh(),但不知道如何.
I have several embedded dashboards as custom controls in my html lightswitch project. They display data manipulated by the user from the database. I would like to set a .refresh() of the object in the afterClosed: event but cannot figure out how.
这是我实例化呈现控件的方式.效果很好,但是我该如何刷新.
Here is how I instantiate the control to render. This works fine, but how do I refresh.
myapp.screenName.CustomControl_render = function (element, contentItem) {
// Write code here.
msls.promiseOperation(CallGetUserNames).then(function PromiseSuccess(PromiseResult) {
var userRef = PromiseResult;
var dash = $(
"<script type='text/javascript' src='http://server/javascripts/api/viz_v1.js'></script>" +
"<div class='tableauPlaceholder' style='width: 650px; height: 600px;'>" +
"<object id='myviz' class='tableauViz' width='650' height='600' style='display:none;'>" +
"<param name='host_url' value='myhttpAddress' />" +
"<param name='site_root' value='/x/PrjInstance' />" +
"<param name='name' value='workbookName/dashboardName' />" +
"<param name='tabs' value='no' />" +
"<param name='toolbar' value='true' />" +
"<param name='showVizHome' value='n' />" +
"<param name='showShareOptions' value='true' />" +
"<param name='filter' value='userID=" + userRef + "' />" +
"</object>" +
"</div>");
dash.appendTo($(element));
})
};
一些尝试是尝试.refresh(),databind,创建函数并传递元素& userRef并尝试element.replaceWith(dash),调用_render事件等,但是都失败了.
Some attempts were to try .refresh(), databind, create a function and pass the element & userRef and try element.replaceWith(dash), call the _render event etc. but all failed.
myapp.ScreenName.AddButton_Tap_execute = function (screen) {
// Write code here.
//Create AddNewScreen For Screen Control
myapp.showScreen("AddEditScreenName", null, {
beforeShown: function (AddEditScreen) {
var setNewScreen = new myapp.Entity();
AddEditScreen.Entity = setNewScreen;
},
afterClosed: function (AddedItem, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
screen.Screen_List1.refresh();
screen.Screen_List2.refresh();
screen.Screen_List3.refresh();
msls.promiseOperation(CallGetUserNames).then(function PromiseSuccess(PromiseResult) {
var userRef = PromiseResult;
var $tbwx = $(screen.findContentItem("customControlName"));
setTableau($tbwx, userRef); // Ideal way to refresh the custom control would go here.
});
} else {
}
}
});
};
函数setTableau($ element,userRef){
function setTableau($element, userRef){
//与自定义控件的初始呈现事件基本相同.
// this was essentially the same and the initial render event of the custom control.
}
我认为可能还有另一种方法.
I figure there may be another approach.
推荐答案
找到了一种使用Tableau脚本API的解决方法,但仍想知道如何重新呈现自定义控件.
Found a workaround utilizing the Tableau script API but would still like to know how to re-render a custom control.
var viz = window.tableau.vizs[0];
viz.refresh();
这篇关于如何刷新自定义控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!