protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { hdnButtonText.Value = "Insert"; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else if (e.CommandName == RadGrid.UpdateCommandName) { } else if (e.CommandName == "Edit") { hdnButtonText.Value = "Edit"; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); //GridEditFormItem ed = (GridEditFormItem)e.Item; } //else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) //{ // e.Canceled = true; //} //else //{ // GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); // if (!editColumn.Visible) // editColumn.Visible = true; //} if (e.CommandName == RadGrid.UpdateCommandName) { GridEditableItem gridEditableItem = (GridEditableItem)e.Item; TextBox txt = (TextBox)e.Item.FindControl("TextBox3"); decimal allocationEntry = decimal.Parse(txt.Text); int schemePlanId = int.Parse(RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["SchemeCode"].ToString()); decimal OtherGoalAllocation = decimal.Parse(RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["OtherGoalAllocation"].ToString()); InsertMFInvestmentAllocation(schemePlanId, OtherGoalAllocation, allocationEntry); } }
protected void grvTransmitters_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { e.Canceled = true; //Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); //set initial checked state for the checkbox on init insert newValues["Installed"] = false; newValues["Approved"] = false; //Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); GridEditCommandColumn editColumn = (GridEditCommandColumn)grvTransmitters.MasterTableView.GetColumn("AutoGeneratedEditColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)grvTransmitters.MasterTableView.GetColumn("AutoGeneratedEditColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
public override void AttachProperties(GridColumn gridColumn) { base.AttachProperties(gridColumn); GridEditCommandColumn column = (GridEditCommandColumn)gridColumn; column.ButtonType = GridButtonColumnType.ImageButton; column.HeaderStyle.Width = ButtonColumnWidth; }
public GridEditCommandColumn AddEditCommandColumn(string editText) { GridEditCommandColumn ec = new GridEditCommandColumn(); _grid.MasterTableView.Columns.Add(ec); ec.ButtonType = GridButtonColumnType.ImageButton; ec.EditText = editText; ec.HeaderStyle.Width = ButtonColumnWidth; return(ec); }
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { string editorText = "unknown"; decimal value = 0; if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else if (e.CommandName == RadGrid.UpdateCommandName) { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); TextBox txt = (TextBox)e.Item.FindControl("txtAssumptionValue"); value = decimal.Parse(txt.Text); string assumptionValue = (RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["WA_AssumptionId"].ToString()); //string a = (e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["WA_AssumptionId"]).ToString(); int userId = 0; int customerId = 0; if (assumptionValue == "LE" || assumptionValue == "RA" || assumptionValue == "INR") { userId = userVo.UserId; customerId = customerVo.CustomerId; customerBo.InsertCustomerStaticDetalis(userId, customerId, value, assumptionValue); } else { userId = userVo.UserId; customerId = customerVo.CustomerId; customerBo.UpdateCustomerProjectedDetalis(userId, customerId, value, assumptionValue); } BindAllCustomerAssumptions(); } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
private static void BuildGridEditColumn(BasePage page, RadGrid Grid, Grid GridObject, EditGridColumn Column, string ResourceKeyPrefix) { GridEditCommandColumn col = new GridEditCommandColumn(); string HeaderText = Common.CoalesceStr(col.HeaderText, Column.HeaderText); string Text = Common.CoalesceStr(col.EditText, Column.Text); col.HeaderText = GetGlobalResourceString(page, Column, ResourceKeyPrefix, "HeaderText", HeaderText); col.SortExpression = Common.CoalesceStr(col.SortExpression, Column.SortExpression); col.ButtonType = GridButtonColumnType.LinkButton; col.EditText = GetGlobalResourceString(page, Column, ResourceKeyPrefix, "Text", Text); FormatStyle(col, Column); Grid.MasterTableView.Columns.Add(col); }
public static GridEditCommandColumn GetEditColumn(RadGrid Grid, CodeTorch.Core.Grid GridConfig) { GridEditCommandColumn col = null; CodeTorch.Core.GridColumn editColumn = GridConfig.Columns.Where(c => ( (c is EditGridColumn) ) ) .SingleOrDefault(); if (editColumn != null) { int columnIndex = Enumerable.Range(0, GridConfig.Columns.Count).First(i => GridConfig.Columns[i] is EditGridColumn); col = (GridEditCommandColumn)Grid.MasterTableView.Columns[columnIndex];; } return(col); }
protected void LanesRadGrid_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)LanesRadGrid.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.UpdateCommandName) { // RadTextBox radtxtCageTypeDescr = (RadTextBox)e.Item.FindControl("radtxtCageTypDescrEdit"); } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)LanesRadGrid.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = false; } } if (e.CommandName == "print") { GridDataItem dataItem = (GridDataItem)e.Item; String scageid = dataItem.GetDataKeyValue("lane_id").ToString(); Int32 icageid = Int32.Parse(scageid); string machinename = Shared.UserHostName; string reportname = "7"; string devicetype = "6"; //HttpContext.Current.Response.Write("before calling webservice " + machinename + reportname + devicetype + icageid); PrintService ps = new PrintService(); string test = ps.PrintLabel(reportname, machinename, devicetype, icageid, true); //HttpContext.Current.Response.Write("after print" + test); } }
protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); //GridEditFormItem ed = (GridEditFormItem)e.Item; } if (e.CommandName == RadGrid.UpdateCommandName) { GridEditableItem gridEditableItem = (GridEditableItem)e.Item; TextBox txt = (TextBox)e.Item.FindControl("TextBox3"); TextBox txtotherSIPGoalAllocation = (TextBox)e.Item.FindControl("txtOtherSchemeAllocationPer"); decimal OtherGoalAllocation = decimal.Parse(txtotherSIPGoalAllocation.Text); decimal allocationEntry = decimal.Parse(txt.Text); decimal totalSIPAmount = decimal.Parse(RadGrid2.MasterTableView.DataKeyValues[e.Item.ItemIndex]["TotalSIPamount"].ToString()); int sipId = int.Parse(RadGrid2.MasterTableView.DataKeyValues[e.Item.ItemIndex]["SIPId"].ToString()); InsertMFSIPAllocation(sipId, OtherGoalAllocation, allocationEntry, totalSIPAmount); } }
protected void GridDemoRadGrid_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { GridEditCommandColumn editColumn = (GridEditCommandColumn)GridDemoRadGrid.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)GridDemoRadGrid.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
protected void rgContacts_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { //"Add new" button clicked GridEditCommandColumn editColumn = (GridEditCommandColumn)rgContacts.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)rgContacts.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
protected override void OnItemCommand(GridCommandEventArgs e) { try { base.OnItemCommand(e); //save the expanded/selected state in the session if (e.CommandName == RadGrid.ExpandCollapseCommandName) { SaveOldValues(); //Is the item about to be expanded or collapsed if (!e.Item.Expanded) { //Save its unique index among all the items in the hierarchy this.ExpandedStates[e.Item.ItemIndexHierarchical] = true; } else //collapsed { this.ExpandedStates[e.Item.ItemIndexHierarchical] = false; GridEditCommandColumn editColumn = GetEditCommandColumn((GridDataItem)e.Item); if (editColumn != null && e.Item.IsInEditMode) { SetItemOutOfEditMode(e.Item); Rebind(); } //this.ClearExpandedChildren(e.Item.ItemIndexHierarchical); } } } catch (IndException indExc) { ControlHierarchyManager.ReportError(indExc); return; } catch (Exception exc) { ControlHierarchyManager.ReportError(new IndException(exc)); return; } }
private void DisableEditCommandColumnWhenItemCollapsed(GridDataItem dataItem) { if (dataItem.OwnerTableView.Name == MasterTableView.DetailTables[0].DetailTables[0].Name) { return; } GridEditCommandColumn editColumn = GetEditCommandColumn(dataItem); if (editColumn == null) { return; } if (dataItem.OwnerTableView.Name == MasterTableView.Name) { if (!dataItem.Expanded) { ((ImageButton)dataItem[editColumn].Controls[0]).Enabled = false; return; } bool disableEditCommandMasterItem = true; foreach (GridDataItem detailItem in dataItem.ChildItem.NestedTableViews[0].Items) { if (detailItem.Expanded) { disableEditCommandMasterItem = false; break; } } ((ImageButton)dataItem[editColumn].Controls[0]).Enabled = !disableEditCommandMasterItem; } if (dataItem.OwnerTableView.Name == MasterTableView.DetailTables[0].Name) { ((ImageButton)dataItem[editColumn].Controls[0]).Enabled = dataItem.Expanded; } }
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { decimal value = 0; if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else if (e.CommandName == RadGrid.UpdateCommandName) { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); TextBox txt = (TextBox)e.Item.FindControl("txtAssumptionValue"); if (txt.Text != "") { value = decimal.Parse(txt.Text); } else { value = 0; } string assumptionId = (RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["WA_AssumptionId"].ToString()); adviserFPConfigurationBo.UpdateAdviserAssumptions(adviserVo.advisorId, value, assumptionId); BindAdviserAssumptions(); } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
/// <summary> /// Hides the edit column of this data item if there are no detail items to edit /// </summary> /// <param name="dataItem"></param> private void HideEditCommandColumn(GridDataItem dataItem) { if (dataItem.OwnerTableView.Name == MasterTableView.DetailTables[0].DetailTables[0].Name) { return; } GridEditCommandColumn editColumn = GetEditCommandColumn(dataItem); if (editColumn == null) { return; } if (dataItem.OwnerTableView.Name == MasterTableView.Name) { if (!HasDetailMostChildItems(dataItem)) { if (dataItem.IsInEditMode) { dataItem.Edit = false; } dataItem[editColumn].Controls[0].Visible = false; } } if (dataItem.OwnerTableView.Name == MasterTableView.DetailTables[0].Name) { if (!HasChildItems(dataItem)) { if (dataItem.IsInEditMode) { dataItem.Edit = false; } dataItem[editColumn].Controls[0].Visible = false; } } }
protected void CageTypesRadGrid_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = (GridEditCommandColumn)CageTypesRadGrid.MasterTableView.GetColumn("EditCommandColumn"); editColumn.Visible = false; } else if (e.CommandName == RadGrid.UpdateCommandName) { // RadTextBox radtxtCageTypeDescr = (RadTextBox)e.Item.FindControl("radtxtCageTypDescrEdit"); } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { e.Canceled = true; } else { GridEditCommandColumn editColumn = (GridEditCommandColumn)CageTypesRadGrid.MasterTableView.GetColumn("EditCommandColumn"); if (!editColumn.Visible) { editColumn.Visible = true; } } }
public override GridColumn CreateColumn() { GridEditCommandColumn column = new GridEditCommandColumn(); return(column); }
public static void HandleItemCommand(RadGrid Grid, CodeTorch.Core.Grid GridConfig, object source, GridCommandEventArgs e) { //HANDLE EDIT GRIDS if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked { GridEditCommandColumn editColumn = GetEditColumn(Grid, GridConfig); if (editColumn != null) { editColumn.Visible = false; } } else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) { //dont't allow refreshing of grid while in add mode e.Canceled = true; } else { GridEditCommandColumn editColumn = GetEditColumn(Grid, GridConfig); if (editColumn != null) { if (!editColumn.Visible) { editColumn.Visible = true; } } } //HANDLE EXPORTS if ( (e.CommandName == RadGrid.ExportToCsvCommandName) || (e.CommandName == RadGrid.ExportToExcelCommandName) || (e.CommandName == RadGrid.ExportToPdfCommandName) || (e.CommandName == RadGrid.ExportToWordCommandName) ) { int gridColumnIndex = 0; foreach (CodeTorch.Core.GridColumn column in GridConfig.Columns) { bool isColumnVisible = true; if (column.VisiblePermission.CheckPermission) { isColumnVisible = Common.HasPermission(column.VisiblePermission.Name); } if (isColumnVisible) { bool includeInExport = column.IncludeInExport; if (includeInExport) { if (column.ExportPermission.CheckPermission) { includeInExport = Common.HasPermission(column.ExportPermission.Name); } } if (!includeInExport) { Grid.Columns[gridColumnIndex].Visible = false; } else { if (!String.IsNullOrEmpty(column.ExportDataField)) { switch (column.ColumnType) { case GridColumnType.BoundGridColumn: GridBoundColumn boundcol = ((GridBoundColumn)Grid.Columns[gridColumnIndex]); boundcol.DataField = column.ExportDataField; break; case GridColumnType.HyperLinkGridColumn: GridHyperLinkColumn hypercol = ((GridHyperLinkColumn)Grid.Columns[gridColumnIndex]); hypercol.DataTextField = column.ExportDataField; break; } } } gridColumnIndex++; } } } }
private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { GridEditCommandColumn GEC = new GridEditCommandColumn(); this.RadGrid1.MasterTableView.Columns.Add(GEC); GEC.UniqueName = "EditCommandColumn"; GEC.ButtonType = GridButtonColumnType.ImageButton; GEC.ItemStyle.Width = 20; GEC.OrderIndex = 0; GridButtonColumn GBC = new GridButtonColumn(); this.RadGrid1.MasterTableView.Columns.Add(GBC); GBC.CommandName = "Delete"; GBC.Text = "Delete"; GBC.ItemStyle.Width = 20; GBC.ButtonType = GridButtonColumnType.ImageButton; BLL.CustomFilteringColumn gridColumn2 = new BLL.CustomFilteringColumn(); this.RadGrid1.MasterTableView.Columns.Add(gridColumn2); gridColumn2.DataField = "FirstName"; gridColumn2.HeaderText = "First Name"; gridColumn2.ItemStyle.CssClass = "UseHand"; BLL.CustomFilteringColumn gridColumn3 = new BLL.CustomFilteringColumn(); this.RadGrid1.MasterTableView.Columns.Add(gridColumn3); gridColumn3.DataField = "LastName"; gridColumn3.HeaderText = "Last Name"; BLL.CustomFilteringColumn gridColumn4 = new BLL.CustomFilteringColumn(); this.RadGrid1.MasterTableView.Columns.Add(gridColumn4); gridColumn4.DataField = "Email"; gridColumn4.HeaderText = "Email"; gridColumn4.ItemStyle.Width = 400; GridDateTimeColumn gridColumn5 = new GridDateTimeColumn(); this.RadGrid1.MasterTableView.Columns.Add(gridColumn5); gridColumn5.DataField = "Birthday"; gridColumn5.HeaderText = "Birthday"; gridColumn5.ItemStyle.Width = 200; gridColumn5.AllowFiltering = false; GridCheckBoxColumn gridColumn6 = new GridCheckBoxColumn(); this.RadGrid1.MasterTableView.Columns.Add(gridColumn6); gridColumn6.DataField = "IsLockedOut"; gridColumn6.HeaderText = "Locked Out"; gridColumn6.AllowFiltering = false; //BLL.CustomFilteringColumn gridColumn7 = new BLL.CustomFilteringColumn(); //this.RadGrid1.MasterTableView.Columns.Add(gridColumn7); //gridColumn7.DataField = "Gender"; //gridColumn7.HeaderText = "Gender"; //gridColumn7.AllowFiltering = false; //RadComboBox gridColumn7 = new RadComboBox(); //this.RadGrid1.MasterTableView.Columns.Add(gridColumn7); //gridColumn7.Items[0].Text = "Male"; //gridColumn7.Items[0].Value = "Male"; //gridColumn7.Items[1].Text = "Female"; //gridColumn7.Items[1].Value = "Female"; } }