2013-07-19 2 views
0

Xpages에서 dojox Tree Grid를 빌드하는 방법을 아는 사람이 있습니까? 정보 제공처를 기반으로 그리드를 http://xcellerant.net으로 만들려고했습니다. 데이터베이스보기에서 데이터를로드하는 xAgent를 만들었지 만 테스트 페이지를로드 할 때 오류가 발생했습니다.XPages에서 Dojox 트리 그리드

여기보기 여기

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> 

    <xp:this.afterRenderResponse><![CDATA[#{javascript:// Read view data and write out the JSON data for the categorized grid 
// Each view entry is written out at the top level, but each category has a children property that is an array of IDs of child entries to indent. 
// There can be any number of categorization levels -- just add 'children' properties to child entries. 
// NOTE: It needs the newlines after each line between the write() statements or the browser doesn't see the output as JSON 

var externalContext = facesContext.getExternalContext(); 
var writer = facesContext.getResponseWriter(); 
var response = externalContext.getResponse(); 

response.setContentType('application/json'); 
response.setHeader('Cache-Control', 'no-cache'); 

writer.write("{\n"); 
writer.write("identifier: 'id',\n"); 
writer.write("label: 'name', \n"); 
writer.write("items: [\n"); 

var categoryItem = ""; 
var childItems = ""; 

// Walk the view and build the JSON data 
var vw:NotesView = database.getView('Vrakkoder'); 
var nav:NotesViewNavigator = vw.createViewNav(); 
var ve:NotesViewEntry = nav.getFirst(); 

while (ve != null) { 
    var cv = ve.getColumnValues(); 

    // When a categorized entry is reached: 
    // (a) write out the previous category and children 
    // (b) set up the new category element 
    if (ve.isCategory()) { 
     // Write out the previous category and child entries   
     if (categoryItem != "") { 
      // Trim the trailing comma and space off the category item. 
      // (The child items still need to end with a comma before the next category item starts.) 
      categoryItem = categoryItem.substring(0, categoryItem.length - 2); 
      writer.write("\n" + categoryItem + "] }, \n" + childItems); 
     } 

     // Start building the new category and child entries 
     categoryItem = " {id:'" + cv[0] + "', type: 'vrakgruppe', vrakgruppe:'" + cv[0] + "', children:["; 
     childItems = ""; 

    } else { 
     // This isn't a category, so simultaneously build the children property and the child entries, until the next category is reached. 
     categoryItem += "{_reference:'" + ve.getUniversalID() + "'}, "; 
     childItems += "{id:'" + ve.getUniversalID() + "', vrakode:'" + cv[1] + "', vrak_aarsak_kode:'" + cv[2] + "'}, " 

    } 

    // Get the next entry and recycle the current one 
    var tmpentry = nav.getNext(); 
    ve.recycle(); 
    ve = tmpentry; 
} 


// Write out the last category and children, without the trailing commas 
categoryItem = categoryItem.substring(0, categoryItem.length - 2); 
childItems = childItems.substring(0, childItems.length - 2); 
writer.write("\n" + categoryItem + "] }, \n" + childItems); 

// Close the JSON string 
writer.write("]}"); 
writer.endDocument();}]]></xp:this.afterRenderResponse> 
</xp:view> 

에서 데이터를로드 xAgent의 코드는

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" 
    xmlns:xe="http://www.ibm.com/xsp/coreex" dojoParseOnLoad="true" 
    dojoTheme="true"> 

    <xp:this.resources> 
     <xp:dojoModule name="dojox.grid.TreeGrid"></xp:dojoModule> 
     <xp:dojoModule name="dijit.tree.ForestStoreModel"></xp:dojoModule> 
     <xp:dojoModule name="dojo.data.ItemFileWriteStore"></xp:dojoModule> 

     <xp:styleSheet 
      href="/.ibmxspres/dojoroot/dojox/grid/resources/Grid.css"> 
     </xp:styleSheet> 
     <xp:styleSheet 
      href="/.ibmxspres/dojoroot/dijit/themes/tundra/tundra.css"> 
     </xp:styleSheet> 
     <xp:styleSheet 
      href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraGrid.css"> 
     </xp:styleSheet> 
    </xp:this.resources> 


    <div id="treeGrid"></div> 

    <xp:eventHandler event="onClientLoad" submit="false"> 
     <xp:this.script><![CDATA[var layout = [ 
    { name: "Vrakgruppe", field: "vrakgruppe"}, 
    { name: "Vrakkode", field: "vrakkode"}, 
    { name: "Vrak aarsak kode", field: "Vrak_aarsak_kode"} 
]; 

var jsonStore = new dojo.data.ItemFileWriteStore({ url: "TreeGrid_DataStore.xsp"}); 

var treeModel = new dijit.tree.ForestStoreModel({ 
    store: jsonStore, 
    query: {type: 'vrakgruppe'}, 
    rootId: 'groupRoot', 
    rootLabel: 'Group', 
    childrenAttrs: ['children'] 
}); 

var grid = new dojox.grid.TreeGrid({ 
    treeModel: treeModel, 
    structure: layout 
}, 'treeGrid'); 

grid.startup(); 

dojo.connect(window, "onresize", grid, "resize");]]></xp:this.script> 
    </xp:eventHandler></xp:view> 

은 누군가가 나를 도울 수 xpage

에 트리 그리드를 생성하는 코드이다. 나는 붙어있다.

+0

어떤 오류가 발생 했습니까? 자세한 내용은 XPages 로그 파일을보십시오. OpenNTF의 XPages 로그 파일 판독기를 사용하여 로그 파일에 쉽게 액세스 할 수 있습니다. –

+0

음. Xpage 로그 파일 판독기가 작동하지 않았습니다. 다른 아이디어 – user2599699

+0

작동하지 않았습니까? DB에 서명 했니? 내선이 있나요? lib. 설치 되었습니까? 서버의 ibm_technical_support 폴더에있는 로그 파일을 수동으로보고 실패한 것을 확인할 수 있습니다. –

답변

1

당신은 당신의 솔루션에 매우 가깝습니다. 추가해야 할 유일한 것은 당신의 XAgent 그리드 데이터하지만 몇 가지 추가 헤더 정보도뿐만 아니라 제공이 paramater없이 XAgent "TreeGrid_DataStore.xsp"

enter image description here

-rendered="false"입니다. 브라우저에서 XAgent를 열 때 차이점을 확인할 수 있습니다. rendered="false"

+0

앞으로도 비슷한 문제가있는 사용자의 경우 문제와 방법을 해결할 수 있는지 알아 보는 것이 좋습니다. 일반적인 방법은 http://meta.stackexchange.com/a/5235/223607에 설명되어 있습니다. –