Wednesday, April 08, 2009

Add new Row to webcombo in Client Script

Below are the steps necessary to allow adding and updating to the webcombo:

1. Server side get a hold of the WebGrid that is contained in the WebCombo (WebCombo.Controls[0])

C#

Infragistics.WebUI.UltraWebGrid.UltraWebGrid comboGrid = (Infragistics.WebUI.UltraWebGrid.UltraWebGrid) this.WebCombo1.Controls[0];

VB.NET

Dim comboGrid As Infragistics.WebUI.UltraWebGrid.UltraWebGrid = DirectCast(Me.WebCombo1.Controls(0), Infragistics.WebUI.UltraWebGrid.UltraWebGrid)

2. Then allow add new and updates to the WebGrid

C#

if(comboGrid != null)
{
comboGrid.DisplayLayout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes;
comboGrid.DisplayLayout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
}

VB.NET

If Not comboGrid Is Nothing Then
comboGrid.DisplayLayout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes
comboGrid.DisplayLayout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
End If

3. Write javascript to call the igtbl_addNew method to add a new row to the grid inside of the combo:

JavaScript:

function AddNewRow()
{
var cbo = igcmbo_getComboById('WebCombo1');
var row = igtbl_addNew(cbo.grid.Id, 0);
row.getCell(0).setValue(11);
row.getCell(1).setValue("Name11");
row.getCell(2).setValue(new Date());
}

0 comments: