Thingsboard Dashboard Entities table with Entity Views

房东的猫 提交于 2020-07-09 17:13:39

问题


This issue is very similar to Thingsboard Dashboard Custom Action NullInjectorError

I setup Entities table widget with Datasources from Entity alias like "Entity Views of type 'power_sensor'".

The idea is simple:

  • if Entity View's name is "Powermeter1" - then goto Dashboard state 1
  • else if it is called "Powermeter2" - goto Dashboard state 2

Now I'm going to create Custom action for “On row click ” but fail. I rty to modify @lee-sangjun's code according to entity.service API like this:

var $injector = widgetContext.$scope.$injector;

$injector.get(widgetContext.entityService.get('entityViewService')).getEntity(entityId.id).subscribe(function(entity) {
        if (entity.name == 'Powermeter1') {
            openDashboardState('energy_state_1')
        }
        else if(entity.name == 'Powermeter2') {
            openDashboardState('water_state_2')
        }
});

function openDashboardState(stateId) {
    var params = {
        entityId: entityId,
        entityName: entityName
    }

    widgetContext.stateController.openState(stateId, params,
        false);
}

But nothing happens. What I have to do to make it work?

来源:https://stackoverflow.com/questions/62718109/thingsboard-dashboard-entities-table-with-entity-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!