如何在SAPUI5 TreeTable中设置根目录和子目录路径

时间:2019-01-24 21:26:22

标签: odata sapui5 treetable

我已经查询了oData服务以获取项目列表,并将它们填充到数组中,而不是为每个项目插入任务

但是如何在SAPUI5 TreeTable中显示它们?

In [11]: pd.to_datetime(a)
Out[11]:
DatetimeIndex(['2013-12-14', '2013-12-14', '2013-12-24', '2013-12-25',
               '2013-12-25', '2013-12-25'],
              dtype='datetime64[ns]', freq=None)

In [12]: pd.to_datetime(a).value_counts()
Out[12]:
2013-12-25    3
2013-12-14    2
2013-12-24    1
dtype: int64

In [13]: pd.to_datetime(a).value_counts().resample('D').sum()
Out[13]:
2013-12-14    2
2013-12-15    0
2013-12-16    0
2013-12-17    0
2013-12-18    0
2013-12-19    0
2013-12-20    0
2013-12-21    0
2013-12-22    0
2013-12-23    0
2013-12-24    1
2013-12-25    3
Freq: D, dtype: int64

如果您在init()中注意到,则将结果数组绑定到树表

onInit: function () {

        var Projects = [];

        var urlSummaryListP =
            "/ProjectProjectSummaryTaskCollection?$format=json&$filter=ResponsibleEmployeeUUID eq guid'x-x-x-x-x' and ParentTaskUUID eq null&$expand=Project";

        // create an entry of the Products collection with the specified properties and values
        var serviceUrl1 = "/destinations/BYD/sap/byd/odata/cust/v1/odata_project" + urlSummaryListP;

        var odataMod = new sap.ui.model.odata.ODataModel(serviceUrl1, true);


       //getTreeTable
        var oTreeTable = this.getView().byId("treeTable");
        //Get Projects
        odataMod.read(
            "/",
            null, [],
            true,
            function (oData, oResponse) {
                var data = oData.results;

                data.forEach(function (item) {

                    item.ObjectType = "Chevron";
                    item.HierarchyNodeLevel = 0;
                    item.IsCriticalPath = false;
                    item.IsProjectMilestone = false;
                    item.DrillDownState = "expanded";
                    item.TasksProject = [];
                    Projects.push(item);

                });

             //Get Projects Tasks
                Projects.forEach(function (task) {
                    var urlProjectTask = 'ProjectCollection(\'' + task.ObjectID +
                        '\')/ProjectTask?$format=json';
                    var serviceUrl2 = "/destinations/BYD/sap/byd/odata/cust/v1/odata_project/" + urlProjectTask;
                    var taskQueries = new sap.ui.model.odata.ODataModel(serviceUrl2, true);

                    taskQueries.read(
                        "/",
                        null, [],
                        true,
                        function (oDataTask, oResponseTask) {
                            var datatask = oDataTask.results;

                            datatask.forEach(function (ec) {

                                    ec.ObjectType = "Chevron";
                                    ec.HierarchyNodeLevel = 1;
                                    ec.IsCriticalPath = false;
                                    ec.IsProjectMilestone = false;
                                    if (ec.SummaryTaskIndicator == "false" || ec.SummaryTaskIndicator == false)
                                        ec.DrillDownState = "leaf";
                                    else
                                        ec.DrillDownState = "expanded";

                                    task.TasksProject.push(ec);
                                }
                            );
                        });
                });
            }
        );


        var oData = {
            root: {
                name: "root",
                description: "root description",
                checked: false

            }
        };

       //Bind the results to my treeTable   
        oData.root = Projects;
        var oModel = new sap.ui.model.json.JSONModel();
        oModel.setData(oData);
        oTreeTable.setModel(oModel);



.../
}

使用chrome调试时的结果:

   var oData = {
            root: {
                name: "root",
                description: "root description",
                checked: false

            }
        };

         //Bind the results to my treeTable   

     oData.root = Projects;
        var oModel = new sap.ui.model.json.JSONModel();
        oModel.setData(oData);
        oTreeTable.setModel(oModel);

当我输入:var mytreetable = sap.ui.getCore().byId("__xmlview0--treeTable");

结果:

enter image description here

,在每个根节点中,我都有TasksProject数组[]

enter image description here

现在我认为BIG问题是如何设置我的道路的? :

mytreetable.getModel().oData

我尝试了多种组合但无济于事,如何使我的树表显示根对象并显示<t:TreeTable id="treeTable" selectionMode="Single" visibleRowCountMode="Auto" minAutoRowCount="12" selectionBehavior="RowSelector" enableColumnReordering="true" rootLevel="0" rows="{path:'oModel>/root'}" enableSelectAll="false" expandFirstLevel="true"> 数组的子级?

TasksProject

0 个答案:

没有答案