Intersoft WebGrid Documentation
Switching to new Client Side API
See Also Send comments on this topic.
Intersoft WebGrid > Getting Started > Upgrading > Upgrading from previous version > Switching to new Client Side API

Glossary Item Box

Before getting started, the most important knowledge about the new changes is what kind of functions are deleted and what kind of functions are kept.

Global Functions

Global functions are defined as functions which don't belong to an object, and usually used as core function to perform object-independent operation, for example: wgGetCellByName, wgGetRowByRowByPositionExact and so on.

The global functions that kept in the previous version are mostly those which used as getter or setter that do not related to an object model. For example, these functions are still available in previous version:

wgGetGridById ' still supported, but recommended to use ISGetObject
wgGetCellCount
wgGetCellByPosition
wgIsRecordRow
wgGetRootRow

As you can see in the functions above, most of the available functions are those having these pattern "*Get", "*Is", and "*Set" AND those don't have relation to client objects.

 

For example, following functions are related to grid object and hence are obsolete in previous version:
wgSetCheckedRowsData(grid)  - obsolete, changed as method of WebGrid object.
wgGetResponseText(grid) - obsolete, changed as method of WebGrid object.

The obsolete functions above have become part of the object model since it has relation to the object itself. So, to set checked rows data in previous version, you can simply use:

JavaScript Copy ImageCopy Code
var grid = ISGetObject("WebGrid1");
grid.SetCheckedRowsData();

In addition to the obsolete pattern above, all functions that related to an action or task of object are obsolete as well, and have been moved as part of the object model.

For example:
wgMarkEdit(grid) - obsolete, use grid.MarkEdit()
wgExitEdit(grid, params) - obsolete, use grid.ExitEdit(params)


Object Model

The changes to "Members" or also called Properties of existing object model are not significant. 95% of them remain exist with same return value. The significantly changed part are the "Methods" where many new methods are added as the result of obsolete global functions (see section I. above).

Following is the list of existing objects and what have been changed (including new and obsolete methods)

WebGrid object 

Method Name New? Obsolete Replaced With
GettbGBBElement - x GetElement
GettrGBBInfoElement - x GetElement
SetAttribute - x Set (See Common Object Methods)
GetAttribute - x Get (See Common Object Methods)
GetElement x - -


About GetElement method

The WebGrid and WebGridTable object now introduced GetElement method in order to obtain html element of the specified grid's part. The GetElement method replaced the old numerous methods such as GettbGBBElement, GetdvTBElement and so on; which are not effective and difficult to remember.

The GetElement method specification is as following:

WebGrid/WebGridTable
    - GetElement(gridPart, htmlPart)
 

gridPart is the part of the grid you want to obtain. Valid values are:

Value Description
COLHEADER The column header element
COLFOOTER

The column footer element

BODY

The grid's body element

COLHEADERGROUP

The column header group element

COLFOOTERGROUP

The column footer group element

COLGROUP

The body's column group element

GROUPBYBOX

The group by box element

GROUPBYBOXLABEL

The group by box label element

STATUSBAR

The status bar element

STATUSBARRIGHT

The right part of the status bar element

STATUSICON

The icon part of the status bar element

STATUSBARCOMMAND

The command items part of the status bar element

 

htmlPart is the part of html you want to obtain. Valid values are:

Value Description

HTMLDIV

The html DIV tag

HTMLTABLE

The html TABLE tag

HTMLCELL

The html TD tag

HTMLROW

The html TR tag

 

When specifying the values for gridPart and htmlPart, add the "WG40" as the prefix, which is used as the enum variable.

See below example:

Old approach:

Obtaining html table of body: table.gettbTBElement
Obtaining html div of col header : table.gettbCHElement

New approach:

Obtaining html table of body:  table.GetElement(WG40.BODY, WG40.HTMLTABLE)
Obtaining html div of col header:  table.GetElement(WG40.COLHEADER, WG40.HTMLDIV)

The single GetElement method is more effective in the programming model, as the name and parameters are quite easy to be used and recalled.

 

About Get/Set (Common Object Methods)

Get method
Every objects in WebGrid now have Get and Set method.

For example:

JavaScript Copy ImageCopy Code
var grid = ISGetObject("WebGrid1");
alert(grid.Get("Visible"));


The purpose of the Get method is to overcome the limitation in IE's javascript language where there is no way to specify getter and setter.

For example:

grid.Visible           <= resulting what the variable contains.
grid.Get("Visible") <= the object architecture executes the internal getter method (which really quering the visible state of the grid), and then returns the actual result.

However, most of the time both approaches will return the same value when there are no special getter method implemented.

Set method

Most of the time you can assign the value directly to an object, for example:

JavaScript Copy ImageCopy Code
grid.LayoutSettings.AllowGrouping = false;
 

The above codes will affect only during the current runtime, and the changes will not be persisted in future postbacks.

The new object architecture now allowing the persistence of value changed in clients for future postbacks including both OnTheFly postbacks and full page postbacks. This is done by using the special Set method, for example:

JavaScript Copy ImageCopy Code
grid.LayoutSettings.Set("AllowGrouping", false, true);
 

Notice that the set method has one extra parameter, that is to specify whether the value should be persisted for future postbacks.

The exact Set method definition is as following:

object.Set(propertyName, propertyValue, isPersisted); 

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.