Design question: How to add OnClick Handler on a field in WebGrid

34 replies. Last post: October 19, 2010 3:56 PM by Handy Surya
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Eric Member

Hi! I'm creating a new page with the following details:

  • using WebGrid 6.0.7200.220, clients are all IE6
  • hierarchical (all rows have a id and parent_id), lower nodes are loaded on demand
  • Special feature: second column that shows an image (+ or - in a square) to merge all subnodes.

When clicking on this special image, the data of all nodes below the selected row-node are being merged and no folders are shown anymore, only the leaf rows (like files) that are below the selected node (anywhere below). Clicking again should undo everything and return to the folder view.

In InitializeSelfReferenceDataSource I am loading the data below the current node and merging the data into the grid by calling dt.Merge (dt is the DataTable from e.DataSource).

My question would be on how to implement this special feature. When the user clicks on the image I think I should just delete all data below the current node from the RootTable of the grid, then get all data below the current node and merge it into the RootTable.

Now my question is how to implement the onclick event on the image. The image is being added simply by in InitializeRow using e.Row.Cells.GetNamedItem and setting cell.Image="plus.gif". But how do I put a onclick handler on that? And what should it do to refresh the data (requires postback to go to the server somehow).

All times are GMT -5. The time now is 6:28 PM.
Previous Next