简体   繁体   English

Alfresco中的dhtmlxgantt图表分享

[英]dhtmlxgantt Chart in Alfresco Share

my goal is to generate a Alfresco Share page which contains a dhtmlxgantt Chart, which is generated out of a Alfresco site datalist. 我的目标是生成一个Alfresco共享页面,其中包含dhtmlxgantt图表,该图表是从Alfresco站点数据列表中生成的。

What I've accomplished so far: 到目前为止,我已经完成了什么:

  • I have a Datalist which contains all necessary Informations for the gantt Chart. 我有一个数据列表,其中包含甘特图的所有必要信息。

  • I have created a repository script which retrieves the necessary values from the datalist, and the .ftl template presents the values like they need to be to get parsed by the dhtmlxgantt parser ie: 我创建了一个存储库脚本,该脚本从数据列表中检索必要的值,.ftl模板显示的值就像被dhtmlxgantt解析器解析所需的值,即:

{data:[{id:00008,text:'Titel7',start_date:'16-2-2017',duration:6,progress:0.65,open:true}]}; {数据:[{ID:00008,文本:Titel7',起始日期:'16 -2-2017' ,持续时间:6,进展:0.65,开:真}]};

  • I've created an Alfresco Share Page that calls the repository script and gets the gantt Ready json. 我创建了一个Alfresco共享页面,该页面调用存储库脚本并获取gantt Ready json。

  • I've integrated the dhtmlxgantt plugin into the Alfresco share page 我已将dhtmlxgantt插件集成到Alfresco共享页面中

  • The called Json gets Parsed by the gantt Parser 甘特斯Parser解析了被叫Json

The Problem is, that the div where the gantt Bars etc. are in, is so small that only the timeline gets displayed. 问题是,甘特图条等所在的div太小,仅显示时间轴。 I don't know how to change the size of the div because it gets generated by the dhtmlxgantt JavaScript file itself. 我不知道如何更改div的大小,因为它是由dhtmlxgantt JavaScript文件本身生成的。

I can say for sure that the Gantt Bars and the descriptions on the left side are loaded properly, because when I ajust the CSS properties of the div Containers they appear. 我可以肯定地说,甘特图条和左侧的说明已正确加载,因为当我调整div容器的CSS属性时,它们就会出现。 But when I load the page the div are set to a size like there weren't any gantt Bars. 但是,当我加载页面时,div设置为没有任何甘特图条的大小。

Here is what I get when I load the page: just loaded page 这是我加载页面时得到的: 刚刚加载的页面

And that is what i get when I adjust the div sizes in firefox console: loaded and adjusted via firefox 这就是我在firefox控制台中调整div大小时得到的结果: 通过firefox加载和调整

Has anyone else has faced this problem? 还有其他人遇到过这个问题吗?

EDIT: I have now tried it like @vikash suggested. 编辑:我现在已经尝试过了,就像@vikash建议的那样。 I have the following page file (generate-gantt.xml) located in ../alfresco/site-data/pages 我在../alfresco/site-data/pages中有以下页面文件(generate-gantt.xml)

<page>
<template-instance>generate-gantt</template-instance>
<authentication>user</authentication>
</page>

and the template instance file (generate-gantt.xml) located in ../alfresco/site-data/template-instances 以及位于../alfresco/site-data/template-instances中的模板实例文件(generate-gantt.xml)

<template-instance>
   <template-type>org/alfresco/<<temp-type>></template-type>
   <components>

      <component>
         <region-id>gantt</region-id>
         <url>/getDatalistValues</url>
      </component>

   </components>
</template-instance>

"/getDatalistValues" is a repository webscript that i've created and works perfectly. “ / getDatalistValues”是我创建的存储库网页脚本,并且可以完美运行。 It Returns the properly formatted "json" (it's not valid per definition but dhtmlxgantt Needs it in this Format) 它返回格式正确的“ json”(每个定义均无效,但dhtmlxgantt需要此格式)

{

    data:[
        {
            id:00021,
            text:'Overflow',
            start_date:'1-3-2017',
            duration:2,
            progress:0.45,
            open:true
        },
        {
            id:00008,
            text:'Titel7',
            start_date:'16-2-2017',
            duration:6,
            progress:0.65,
            open:true
        },
        {
            id:00010,
            text:'Nachträglich2',
            start_date:'22-2-2017',
            duration:0,
            progress:0.39,
            open:true
        },
        {
            id:00006,
            text:'Titel5',
            start_date:'19-2-2017',
            duration:7,
            progress:0,
            open:true
        }
    ]

};

Also I have the following component (page.gantt.content.xml) located in ../alfresco/site-data/components 我也有位于../alfresco/site-data/components中的以下组件(page.gantt.content.xml)

<?xml version="1.0" encoding="utf-8"?>
    <component>
      <id>page.gantt.content</id>
      <scope>page</scope>
      <region-id>gantt</region-id>
      <source-id>content</source-id>
      <url>/getDatalistValues</url>
    </component>

"getDatalistValues" is the same repository webscript I mentioned above. “ getDatalistValues”是我上面提到的相同的存储库Web脚本。

Last but not least i have the template file (generate-gantt.ftl) located in ../alfresco/templates 最后但并非最不重要的一点是,我在../alfresco/templates中有模板文件(generate-gantt.ftl)

<#include "/org/alfresco/include/alfresco-template.ftl" />
    <@templateHeader></@>
    <@templateBody>
       <@markup id="alf-hd">
       <div id="alf-hd">
          <@region scope="global" id="share-header" chromeless="true"/>
       </div>
       </@>
       <@markup id="bd">
        <div id="bd">
            <@region scope="content" id="gantt"/>
        </div>
       </@>
    </@>
    <@templateFooter>
       <@markup id="alf-ft">
       <div id="alf-ft">
          <@region id="footer" scope="global" />
       </div>
       </@>
    </@>

when I load the page via https://localhost:8080/share/page/generate-gantt . 当我通过https://localhost:8080/share/page/generate-gantt加载页面时。 It generates the ALfresco Header and Footer, but the component is not displayed. 它生成ALfresco页眉和页脚,但不显示该组件。 When I take a look at the html code in Firefox, the div where the component should be gets the id "unbound-region-gantt". 当我看一下Firefox中的html代码时,应该在其中放置组件的div的ID为“ unbound-region-gantt”。 Do anyone see my mistake? 有人看到我的错误吗? And the orther question is, where do I place the .js file that processes the result of the "/getDatalistValues" script, and parses it to generate the gantt Chart out of the result? 还有一个问题是,我应该在哪里放置处理“ / getDatalistValues”脚本结果的.js文件,并对其进行解析以从结果中生成甘特图?

dhtmlxGantt inherits size of its html container unless you specify otherwise, same true for dhtmlxScheduler. 除非您另外指定,否则dhtmlxGantt会继承其html容器的大小,对于dhtmlxScheduler来说也是如此。 Try setting some default height, eg 尝试设置一些默认高度,例如

HTML: HTML:

<div id="gantt_here"></div>

CSS: CSS:

#gantt_here { 
    height: 600px; 
}

JS: JS:

gantt.init("gantt_here");

If you use relative sizes (eg height:100%) - make sure that the parent element also have some initial height, otherwise you'll get 100% from 0px 如果您使用相对大小(例如,高度:100%),请确保父元素也具有一些初始高度,否则您将获得0px的100%

to create a surf page refer this link. 要创建冲​​浪页面,请参考此链接。 http://docs.alfresco.com/5.0/tasks/dev-extensions-share-tutorials-add-page.html http://docs.alfresco.com/5.0/tasks/dev-extensions-share-tutorials-add-page.html

If you wanted to get display your data in this page so you have to bind your webscript component to this page ex. 如果要在此页面上显示数据,则必须将Web脚本组件绑定到此页面。

ftl file. ftl文件。

<#include "/org/alfresco/include/alfresco-template.ftl" />
<@templateHeader></@>
<@templateBody>
   <@markup id="alf-hd">
   <div id="alf-hd">
      <@region scope="global" id="share-header" chromeless="true"/>
   </div>
   </@>
   <@markup id="bd">
    <div id="bd">
        <@region scope="template" id="test-id"/>
    </div>
   </@>
</@>
<@templateFooter>
   <@markup id="alf-ft">
   <div id="alf-ft">
      <@region id="footer" scope="global" />
   </div>
   </@>
</@>

template-instance file 模板实例文件

<template-instance>
   <template-type>org/alfresco/<<temp-type>></template-type>
   <components>

      <component>
         <region-id>test-id</region-id>
         <url>/components/test-url</url>
      </component>

   </components>
</template-instance>

This tag's ID must be same as your component's id which you have to define in your template-instance files for creating component refer this link 此标记的ID必须与您在模板实例文件中定义的用于创建组件的组件的ID相同。

http://docs.alfresco.com/5.2/references/surf-object-xml-reference-component.html http://docs.alfresco.com/5.1/concepts/dev-extensions-share-surf-web-scripts.html http://docs.alfresco.com/5.2/references/surf-object-xml-reference-component.html http://docs.alfresco.com/5.1/concepts/dev-extensions-share-surf-web-scripts html的

<@region scope="template" id="test-id"/>

refer this link for creation of webscript component 请参考此链接来创建网页脚本组件

http://docs.alfresco.com/5.1/concepts/dev-extensions-share-surf-web-scripts.html your webscript url must be same as coponent's url http://docs.alfresco.com/5.1/concepts/dev-extensions-share-surf-web-scripts.html您的Web脚本网址必须与对应的网址相同

 <url>/components/test-url</url>

from webscripts js you can call your repo wescript by using AJAX or you can call using 从webscripts js中,您可以使用AJAX调用您的回购wescript,也可以使用

 var result = connector.get("/repo-webscript-url");
if (result.status.code == status.STATUS_OK) {
    var siteJSON = jsonUtils.toObject(result);
}

for creating repo webscript refer this http://www.krutikjayswal.com/2016/10/alfresco-webscript-spring-webscript.html 有关创建回购网页脚本的信息,请参阅此http://www.krutikjayswal.com/2016/10/alfresco-webscript-spring-webscript.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM