Hello,
My requirement is adding dropdown in the WebGrid cell. I have achieved this by using validation, but after using validaion I have lost a control on context menu (CustomCommand button). Context menu has displayed but Server Side acWGTemplateField_CustomCommand event does not fired. Can you please help me out to solve this issue? Is it possible to fire a server side event like SelectionIndexChanged or SelectionValueChanged events for dropdown?
I am using Licence Version 2.7.8.2000
///Client Side Script
<script type="text/javascript" language="javascript">
function ShowAttributeForm(column, row) {
alert("column : " + (column+1) + " row : " + (row+1));
}
function onContextMenuShow() {
var menu = event.srcElement;
//menu.setItemVisibility("Delete", "block");
// menu.setItemVisibility("Update", "none");
//callServerEvent();
}
function callServerEvent() {
__doPostBack("acWGTemplateField", "acWGTemplateField_CustomCommand");
}
function onCellSelected(cell) {
//var cell = acWGTemplateField.getActiveCell();
//alert("Cell row:" + igWGBTemplateField_acWGTemplateField.getActiveRow() + " Cell column: " + igWGBTemplateField_acWGTemplateField.getActiveColumn());
if (document.getElementById("hdnActiveRow")) {
document.getElementById("hdnActiveRow").value = acWGTemplateField.getActiveRow();
}
if (document.getElementById("hdnActiveColumn")) {
document.getElementById("hdnActiveColumn").value = acWGTemplateField.getActiveColumn();
}
}
function DoubleClickCellClientFunction(sender, args) {
alert("Double Click Event :: Row : " + (acWGTemplateField.getActiveRow()+1) + " Column : " + (acWGTemplateField.getActiveColumn()+1));
}
function CellUpdatedClientFunction(sender, args) {
alert("Cell Focus Lost Event :: Row : " + (acWGTemplateField.getActiveRow()+1) + " - Column : " + (acWGTemplateField.getActiveColumn()+1) + " - Column Name : " + sender.childNodes[0].outerText);
}
</script>
///Aspx page code
<table id="tblMain" cellpadding="0" cellspacing="0" border="0" class="MainTable"><tr><td><table><tr><td> <acw:GridWeb ID="acWGTemplateField" runat="server" Width="100%" Height="658px" ShowLoading="false" ShowContextMenu="true" EditMode="true" OnCustomCommand="acWGTemplateField_CustomCommand" ShowBottomBar="False" OnCellUpdatedClientFunction="CellUpdatedClientFunction" EnableDoubleClickEvent="True" OnDoubleClickCellClientFunction="DoubleClickCellClientFunction" XhtmlMode="True" ShowSaveButton="False" OnContextMenuShowClientFunction="onContextMenuShow" ShowSubmitButton="False" ShowUndoButton="False" OnCellSelectedClientFunction="onCellSelected" >
<CustomCommandButtons> <acw:CustomCommandButton Command="InsertColumn" Text="Insert Column" CommandType="ContextMenuItem"></acw:CustomCommandButton>
<acw:CustomCommandButton Command="DeleteColumn" Text="Delete Column" CommandType="ContextMenuItem"></acw:CustomCommandButton>
<acw:CustomCommandButton Command="InsertRow" Text="Insert Row" CommandType="ContextMenuItem"></acw:CustomCommandButton>
<acw:CustomCommandButton Command="DeleteRow" Text="Delete Row" CommandType="ContextMenuItem"></acw:CustomCommandButton>
</CustomCommandButtons>
</acw:GridWeb></td></tr></table>
<asp:HiddenField ID="hdnActionMode" runat="server" ClientIDMode="Static" /><asp:HiddenField ID="hdnActiveRow" runat="server" ClientIDMode="Static" Value="0" /><asp:HiddenField ID="hdnActiveColumn" runat="server" ClientIDMode="Static" Value="0" /></td></tr></table>
///Server side code
protected void Page_Load(object sender, EventArgs e)
{
Aspose.Cells.GridWeb.License license = new Aspose.Cells.GridWeb.License();
license.SetLicense("Aspose.Cells.lic");
if (!IsPostBack)
{
LoadTemplateFieldData();
//acWGTemplateField.EditMode = false;
}
}
private void LoadTemplateFieldData()
{
acWGTemplateField.WebWorksheets.Clear();
acWGTemplateField.WebWorksheets.Add("Sample Aspose");
#region Sample
WebWorksheet sheet = acWGTemplateField.WebWorksheets[0];
Aspose.Cells.GridWeb.TableItemStyle style = new Aspose.Cells.GridWeb.TableItemStyle();
sheet.Cells[1, 0].PutValue("Jack");
sheet.Cells[1, 1].PutValue("M");
sheet.Cells[1, 2].PutValue(19);
sheet.Cells[1, 3].PutValue("One");
sheet.Cells[2, 0].PutValue("Tome");
sheet.Cells[2, 1].PutValue("M");
sheet.Cells[2, 2].PutValue(20);
sheet.Cells[2, 3].PutValue("Four");
sheet.Cells[3, 0].PutValue("Jeney");
sheet.Cells[3, 1].PutValue("W");
sheet.Cells[3, 2].PutValue(18);
sheet.Cells[3, 3].PutValue("Two");
sheet.Cells[4, 0].PutValue("Marry");
sheet.Cells[4, 1].PutValue("W");
sheet.Cells[4, 2].PutValue(17);
sheet.Cells[4, 3].PutValue("There");
sheet.Cells[5, 0].PutValue("Amy");
sheet.Cells[5, 1].PutValue("W");
sheet.Cells[5, 2].PutValue(16);
sheet.Cells[5, 3].PutValue("Four");
sheet.Cells[6, 0].PutValue("Ben");
sheet.Cells[6, 1].PutValue("M");
sheet.Cells[6, 2].PutValue(17);
sheet.Cells[6, 3].PutValue("Four");
// DropDownList.
CreateDropDown(sheet.Cells[1, 0]);
CreateDropDown(sheet.Cells[1, 1]);
CreateDropDown(sheet.Cells[1, 2]);
CreateDropDown(sheet.Cells[1, 3]);
CreateDropDown(sheet.Cells[2, 0]);
CreateDropDown(sheet.Cells[2, 1]);
CreateDropDown(sheet.Cells[2, 2]);
CreateDropDown(sheet.Cells[2, 3]);
this.acWGTemplateField.EnableDoubleClickEvent = true;
acWGTemplateField.ShowBottomBar = false;
#endregion
}
private void CreateDropDown(WebCell cell)
{
cell.CreateValidation(Aspose.Cells.GridWeb.ValidationType.DropDownList, true);
cell.Validation.ValueList.Add("Bachelor");
cell.Validation.ValueList.Add("Master");
cell.Validation.ValueList.Add("Doctor");
}
protected void acWGTemplateField_CustomCommand(object sender, string command)
{
int column = (((Aspose.Cells.GridWeb.GridWeb)(sender)).ActiveCell).Column;
int Row = (((Aspose.Cells.GridWeb.GridWeb)(sender)).ActiveCell).Row;
switch (command)
{
case "InsertColumn":
acWGTemplateField.WebWorksheets[0].Cells.InsertColumn(column);
break;
case "DeleteColumn":
acWGTemplateField.WebWorksheets[0].Cells.DeleteColumn(column);
break;
case "InsertRow":
acWGTemplateField.WebWorksheets[0].Cells.InsertRow(Row);
break;
case "DeleteRow":
acWGTemplateField.WebWorksheets[0].Cells.DeleteRow(Row);
break;
}
acWGTemplateField.EditMode = true;
}
Appriciate quick reply
Regards,
Nilesh Dhote