Wednesday, September 18, 2013

Caching display methods with Client modifier

Caching display methods can increase performance in some cases. But be cautious when you are adding them in datasource Init method. If by mistake you add one method that defined with Client modifier on the table, it will fail right calculations for them all for the first line in the grid.

For example, you have one method on the table with Client modifier:

display client Integer isLineChanged()

    if (this.Changed)
        return #ImageInfo;

    return 0;

On the form you add this method amongst others in cache (not the last one!):

// Form DataSource Init method
public void init()
    this.cacheAddMethod(tablemethodstr(myTable, errorExist));
    this.cacheAddMethod(tablemethodstr(myTable, isLineChanged));
    this.cacheAddMethod(tablemethodstr(myTable, itemName));
    this.cacheAddMethod(tablemethodstr(myTable, categoryName));
    this.cacheAddMethod(tablemethodstr(myTable, subCategoryName));

You will get the following result because all of these methods will be calculated based on client side buffer that is not fetched yet.

It does not matter if you place a cached display method in the form or not -- it is calculated anyway.

No comments: