Intersoft Support Center

Extend Data Editing with Client-side APIs

WebGrid Enterprise's key design is to enable seamless interactions between client and server. In previous version, many tasks become difficult to be implemented because the limitation of the architecture. The new version’s improvements in the core architecture now allow you to perform client tasks easily. To give you an idea of what is possible, here we list a few of commonly used tasks:

  • SetFocus can be called from server side to force focus to specify grid at page load.
  • Selected row can now be set from server side through SetSelectedObject method.
  • Selected object’s element can now be consistently obtained regardless of whether it is at root or any level of child tables.
  • Added several new client side events, such as OnButtonClick, OnFocus, OnLostFocus and more.

The tutorial for this enhancement can be found in ServerProgrammability.aspx.

Sample code:

JavaScript Copy ImageCopy Code
private void WebGrid1_Load(object sender, System.EventArgs e)
{
    if (!IsPostBack)
    {
        // always select first row on first page load
        WebGrid1.SetSelectedObject(new SelectedObject(WebGrid1.RootTable, 0));
                
        // set focus to grid
        WebGrid1.SetFocus();
                
        // in v3.5, this event indicates that the datasource has been populated
        // and rows has been loaded so you can access row's value directly.
        // let's try to change the second row's style.
        WebGrid1.RootTable.Rows[1].Style.BackColor = Color.AliceBlue;
                
        // access to cell
        WebGrid1.RootTable.Rows[2].Cells[0].Text = "New Text";
    }
}
Previous Next