Log in / create account
View source | Discuss page | Page history | Printable version   
360 Tour
ADVERTISEMENT
Accounting eLearning Courses
Partnerships
SourceForge.net Logo
Openbravo ERP at SourceForge

SourceForge.net Logo
Openbravo POS at SourceForge

Open Solution Alliance Logo
Openbravo at Open Solution Alliance

Grid widget on Manual Windows

Rating :
N/A
(0 votes cast)
You have to be registered to be able to vote

This document is still a work in progress. It may contain inaccuracies or errors.


Contents

Introduction

Glossary

The AJAX grid widget overview

Note: Further details will be explained later. This is an overview.

HTML

The html has three DIV containters (client_top, client_middle, client_bottom). This has also new JavaScript functions to handle the grid actions (filter, select).


The grid DIV tag

<DIV id="grid" dojotype="openbravo:DataGrid" structureurl="../info/BusinessPartner.html?Command=STRUCTURE" dataurl="../info/BusinessPartner.html?Command=DATA" updatesurl="../info/BusinessPartner_F1.html?Command=DATA" calculatenumrows="true" editable="false" sortable="true" deleteable="true" oninvalidvalue="alert" onscroll="updateHeader" ongridload="onGridLoadDo" buffersize="3.0" showlinenumbers="true" offset="" sortcols="1" sortdirs="ASC" defaultrow="0" maxwidth="99%" percentagewidthrelativetoid="client_middle" multiplerowselection="false" preventcache="true" usecache="true" cachecontent="false">

</DIV>
<SCRIPT>djConfig.searchIds.push("grid");</SCRIPT>


JavaScript

Several javascript functions were added to the page.

The list of files to include:

<SCRIPT language="JavaScript" src="../web/js/openbravo/widget/DataGrid.js" type="text/javascript"></SCRIPT>
<SCRIPT language="JavaScript" src="../web/js/windowKeyboard.js" type="text/javascript"></SCRIPT>
<SCRIPT language="JavaScript" src="../web/js/searchs.js" type="text/javascript"></SCRIPT>

XML

You need to add the the xml parameters for the grid:

    <PARAMETER id="grid" name="grid" attribute="numrows" />
    <PARAMETER id="grid" name="grid_Offset" attribute="offset" />
    <PARAMETER id="grid" name="grid_SortCols" attribute="sortcols" />
    <PARAMETER id="grid" name="grid_SortDirs" attribute="sortdirs" />

<PARAMETER id="grid" name="grid_Default" attribute="defaultrow" />

Java

void printPage() {
...
    xmlDocument.setParameter("grid", "20");
    xmlDocument.setParameter("grid_Offset", "");
    xmlDocument.setParameter("grid_SortCols", "1");
    xmlDocument.setParameter("grid_SortDirs", "ASC");
    xmlDocument.setParameter("grid_Default", "0");
...
}
void printGridStructure(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException {
}
void printGridData(HttpServletResponse response, VariablesSecureApp vars, String strKey, String strName, String strContact, String strZIP, String strProvincia, String strBpartners, String strCity, String strOrderBy, String strOffset, String strPageSize ) throws IOException, ServletException {
}
private SQLReturnObject[] getHeaders(VariablesSecureApp vars) {
}

/* The colum name are retreived from database. You need to add a new message for each column of the selector. In this case a suffix of BPS_ was used (stands for Business Partner Selector) If the key was not found, the column name is used */

private SQLReturnObject[] getHeaders(VariablesSecureApp vars) {
     ...
      for(int i=0; i < colNames.length; i++) {
...
          String name = Utility.messageBD(this, "BPS_" + colNames[i].toUpperCase(), vars.getLanguage());
          dataAux.setData("name", (name.startsWith("BPS_")?colNames[i]:name));
...      
}
...
}

/* Handling the Oracle/PostgreSQL limit*/

E.g.

          // Filtering result
        if(this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
            String oraLimit = strOffset + " AND " + String.valueOf(Integer.valueOf(strOffset).intValue() + Integer.valueOf(strPageSize));            
            data = BusinessPartnerData.select(this, "ROWNUM", Utility.getContext(this, vars, "#User_Client", "BusinessPartner"), Utility.getContext(this, vars, "#User_Org", "BusinessPartner"), strKey, strName, strContact, strZIP, strProvincia, (strBpartners.equals("costumer")?"clients":""), (strBpartners.equals("vendor")?"vendors":""), strCity, strOrderBy, oraLimit, "");
        }
        else {
            String pgLimit = strPageSize + " OFFSET " + strOffset;
            data = BusinessPartnerData.select(this, "1", Utility.getContext(this, vars, "#User_Client", "BusinessPartner"), Utility.getContext(this, vars, "#User_Org", "BusinessPartner"), strKey, strName, strContact, strZIP, strProvincia, (strBpartners.equals("costumer")?"clients":""), (strBpartners.equals("vendor")?"vendors":""), strCity, strOrderBy, "", pgLimit);
        }


Reponses examples

Structure

<xml-structure>
  <status>
    <type>Hidden</type>
    <title></title>
    <description></description>
  </status>
  <datagrid readonly="true" fixed="false">
    <columns>
      <column name="value" identifier="false" visible="true" title="Key" type="string" width="98px"></column>
      <column name="name" identifier="false" visible="true" title="Name" type="string" width="172px"></column>
      <column name="so_creditavailable" identifier="false" visible="true" title="Disp. Credit" type="string" width="50px"></column>
      <column name="so_creditused" identifier="false" visible="true" title="Credit used" type="string" width="83px"></column>
      <column name="contact" identifier="false" visible="true" title="Contact" type="string" width="104px"></column>
      <column name="phone" identifier="false" visible="true" title="Phone" type="string" width="63px"></column>
      <column name="pc" identifier="false" visible="true" title="Zip" type="string" width="43px"></column>
      <column name="city" identifier="false" visible="true" title="City" type="string" width="100px"></column>
      <column name="income" identifier="false" visible="true" title="Income" type="string" width="63px"></column>
      <column name="c_bpartner_id" identifier="false" visible="false" title="c_bpartner_id" type="string" width="0px"></column>
      <column name="c_bpartner_contact_id" identifier="false" visible="false" title="c_bpartner_contact_id" type="string" width="0px"></column>
      <column name="c_bpartner_location_id" identifier="false" visible="false" title="c_bpartner_location_id" type="string" width="0px"></column>
      <column name="rowkey" identifier="true" visible="false" title="rowkey" type="string" width="0px"></column>
    </columns>
  </datagrid>
</xml-structure> 


Data

<xml-data>
  <status>
    <type><![CDATA[Hidden]]></type>
    <title><![CDATA[]]></title>
    <description><![CDATA[]]></description>
  </status>
  <rows numRows="1">
    <tr>
      <td><![CDATA[10000238]]></td>
      <td><![CDATA[The South Bank]]></td>
      <td><![CDATA[-1823.86]]></td>
      <td><![CDATA[1823.86]]></td>
      <td><![CDATA[]]></td>
      <td><![CDATA[]]></td>
      <td><![CDATA[ ]]></td>
      <td><![CDATA[Capital of Maine]]></td>
      <td><![CDATA[ ]]></td>
      <td><![CDATA[1004342]]></td>
      <td><![CDATA[]]></td>
      <td><![CDATA[1004091]]></td>
      <td><![CDATA[1004342##1004091]]></td>
    </tr>
  </rows>
</xml-data>

XSQL

The xsql was modified to permit the limit of a resultset. To the previous sql clause you need to add:

<SqlMethod name="select" type="preparedStatement" return="multiple">
      <SqlMethodComment></SqlMethodComment>
      <Sql> <![CDATA[

SELECT * FROM ( SELECT '0' AS RN1, A.* FROM (

{PREVIOUS SELECT}

) A ) B

            WHERE 1=1

]]></Sql>

<Parameter name="rownum" type="replace" optional="true" after="FROM ( SELECT " text="'0'" />
{PREVIOUS PARAMETERS}
<Parameter name="oraLimit" type="argument" optional="true" after="WHERE 1=1" text="bp.value"><![CDATA[AND RN1 BETWEEN ]]></Parameter>
        <Parameter name="pgLimit" type="argument" optional="true" after="WHERE 1=1" text="bp.value"><![CDATA[LIMIT ]]></Parameter>=== Application Dictonary ===

Retrieved from "http://wiki.openbravo.com/wiki/Grid_widget_on_Manual_Windows"

This page has been accessed 697 times. This page was last modified 11:19, 31 July 2008. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.


Category: Development