Package com.smartgwt.client.docs

# Interface StringMethods

public interface StringMethods

### String Methods Overview

A method flagged as a `StringMethod` can be specified as a String containing a valid JavaScript expression. This expression will automatically be converted to a function with a return value matching the value of the last statement. Providing a String is not required - you may use a real function instead.

For example - suppose you wanted to override the `leafClick()` method on the TreeGrid. Normally you would do so as follows:

      TreeGrid.create({
          ...
          leafClick : function(viewer, leaf, recordNum) {
              if(leaf.name == 'zoo') {
                  alert(1);
              } else {
                  alert(2);
              }
          }
      });

Since leafClick is a `StringMethod`, however, you can shorten this to:

      TreeGrid.create({
          ...
          leafClick : "if(leaf.name == 'zoo') { alert(1); } else { alert(2); }";
      });