Library Configuration

Smartsite 7.7 - ...

The Library Configuration contains the configuration required for building a library action for a specific table.

The example below shows the library configuration for the LogEntries library.

XML CopyCode image Copy Code
<libraryconfiguration>
  <columns namecolumn="substring(message,0,50) as message">
    <column name="timestamp" caption="TIMESTAMP" columntype="DateTime" />
    <column name="message" caption="MESSAGE" />
    <column name="typename" caption="Type" />
    <column name="categoryname" caption="CATEGORY" />
    <column name="loglevel" caption="Level" />
  </columns>
  <sortorders>
    <sortorder sqlclause="c.timestamp desc" caption="TIMESTAMP" />
    <sortorder sqlclause="c.nr" caption="Nr" />
  </sortorders>
  <mastersql>
    select %selectfields% from vwLogEntries c
    %joins%
    where (c.Message like '%%searchfor%%' or c.ContextData like '%%searchfor%%')
    %wheres%
  </mastersql>
  <tablealias>c</tablealias>
  <rowdetailssql>
    select c.Nr, dbo.fn_Ellipsis(c.Message, 100) as Message, c.Timestamp, c.Typename, c.CategoryName, c.LogLevel
    from vwLogEntries c
    where c.Nr in (?)
  </rowdetailssql>
  <librarydetails>
    <sql>
      select c.Nr, c.Timestamp, dbo.fn_Ellipsis(c.Message, 100) as Message, c.Typename as Type,
      c.CategoryName as Category, c.LogLevel as Level
      from vwLogEntries c
      where c.Nr in (?)
    </sql>
  </librarydetails>
  <detailsaction>
    <sql>
      select c.Nr, c.Timestamp, c.Message, c.Typename as Type, c.CategoryName as Category, c.LogLevel as Level, c.ContextData
      from vwLogEntries c
      where c.Nr in (?)
    </sql>
  </detailsaction>
  <facets>
    <facet title="Category">
      <name>logcategory</name>
      <selectfield>CategoryNr</selectfield>
      <query>
        select top 10 ft.Nr, ft.Name, count(ft.Nr) as cnt
        from (%mastersql%) x
        join LogCategories ft on x.CategoryNr = ft.Nr
        group by ft.Nr, ft.Name
        order by cnt desc
      </query>
    </facet>
    <facet title="Type">
      <name>logtype</name>
      <selectfield>TypeNr</selectfield>
      <query>
        select top 10 ft.Nr, ft.Name, count(ft.Nr) as cnt
        from (%mastersql%) x
        join LogTypes ft on x.TypeNr = ft.Nr
        group by ft.Nr, ft.Name
        order by cnt desc
      </query>
    </facet>
  </facets>
  <buttons>
    <remove name="edit" />
    <remove name="add" />
    <remove name="duplicate" />
  </buttons>
</libraryconfiguration>

The library configuration supports several more elements to configure the look and feel of the library.
All of the supported elements are described below.

title

Sets the title for the library action. Defaults to the table name.

columns

Defines the columns which are displayed within the library. The list of columns must correspond with the selected fields of the sql query within the rowdetailssql element.

The name attribute must be specified within lower-case. The caption attribute will be used as row header label and its value will be localized if there's a corresponding localization string.

Using the optional columntype attribute, you can specify the type of data that will be displayed within the column. 
Supported values are: String (which is the default), HtmlString, Integer, BooleanYesNo, DateTime.

sortorders

Contains one or more sortorders. The sqlclause attribute defines the "order by" sql clause and the caption attribute defines the display value, which will be localized when possible.

mastersql

Contains the master sql statement to be used within the library. The query should contain the following placeholders:

  • %selectfields%
  • %joins%
  • %wheres%
  • %%searchfor%%

You should also use an alias for the table, which must correspond with the value specified within the tablealias element.

tablealias

The alias used within the master sql query as specified in the mastersql element.

rowdetailssql

Specifies the query which will be used to retrieve the row details. Should contain a where statement like: "where c.Nr in (?)".
The select list should contain (at least) the same columns as the columns specified within the columns element.

librarydetails

When a row is selected, the libray will display details about the record on the right of the screen. Include the librarydetails element, with a sql child element, to specify a custom query which should be used to render these details.

When this element is omitted, the query as specified within the rowdetailssql element will be used to render the details.

detailsaction

Besides the details shown on the right of the screen when a row is selected (librarydetails element or rowdetailssql as fallback), you can add a detailsaction element within the library configuration, with a sql child element which specifies a query to display even more details for a selected row.

When this element is present within the library configuration, a details button will be available within the library's button bar. The specified query will be used to render the details action.

facets

Element which can be used to specify one or more facets

Example:

XML CopyCode image Copy Code
<facet title="Category">
   <name>logcategory</name>
   <selectfield>CategoryNr</selectfield>
   <query>
     select top 10 ft.Nr, ft.Name, count(ft.Nr) as cnt
     from (%mastersql%) x
     join LogCategories ft on x.CategoryNr = ft.Nr
     group by ft.Nr, ft.Name
     order by cnt desc
   </query>
 </facet>

buttons

The buttons element can be used to remove one or more of the default buttons shown in the library. The default buttons include: edit, add, delete and duplicate. Just add a remove element with a name attribute, corresponding to the button which should not be included within the library.

Topics