protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e) { GridTableView tableView = e.Item.OwnerTableView; e.Canceled = true; GridSortExpression expression = new GridSortExpression(); expression.FieldName = "Customer"; if (tableView.SortExpressions.Count == 0 || tableView.SortExpressions[0].FieldName != "Customer") { expression.SortOrder = GridSortOrder.Descending; } else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Descending) { expression.SortOrder = GridSortOrder.Ascending; } else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Ascending) { expression.SortOrder = GridSortOrder.None; } tableView.SortExpressions.AddSortExpression(expression); tableView.Rebind(); LoadDataForRadGrid1(); RadGrid1.DataBind(); }
private void ApplyStyleSheetsForExport(GridTableView gridTableView) { if (null != gridTableView.GetItems(GridItemType.Header) && gridTableView.GetItems(GridItemType.Header).Count() > 0) { gridTableView.Columns.FindByUniqueName("SelectionChecBox").Visible = false; gridTableView.Columns.FindByUniqueName("FollowUp").Visible = false; GridItem headerItem = gridTableView.GetItems(GridItemType.Header)[0]; headerItem.Style["font-size"] = "8pt"; headerItem.Style["color"] = "black"; headerItem.Style["height"] = "15px"; headerItem.Style["font-weight"] = "bold"; headerItem.Style["vertical-align"] = "middle"; headerItem.Style["width"] = "10px"; foreach (TableCell tableCell in headerItem.Cells) { tableCell.Wrap = true; tableCell.Style["text-align"] = "center"; tableCell.Style["font-weight"] = "bold"; tableCell.Style["font-size"] = "5pt"; } GridItem[] items = gridTableView.GetItems(GridItemType.Item); GridItem[] alternatingItems = gridTableView.GetItems(GridItemType.AlternatingItem); ApplyGridItemStyle(items); ApplyGridItemStyle(alternatingItems); } }
public void HideExpandColumnRecursive(GridTableView tableView) { GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { nestedView.Style["border"] = "0"; Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton"); if (nestedView.Items.Count == 0) { if (MyExpandCollapseButton != null) { MyExpandCollapseButton.Style["visibility"] = "hidden"; } nestedViewItem.Visible = false; } else { if (MyExpandCollapseButton != null) { MyExpandCollapseButton.Style.Remove("visibility"); } } if (nestedView.HasDetailTables) { HideExpandColumnRecursive(nestedView); } } } }
/// <summary> /// Hides the expand column recursive. /// </summary> /// <param name="tableView">The table view.</param> private void HideExpandColumnRecursive(GridTableView tableView) { GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { nestedView.Style["border"] = "0"; var myExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton"); if (nestedView.Items.Count == 0) { if (myExpandCollapseButton != null) { myExpandCollapseButton.Style["visibility"] = "hidden"; } nestedViewItem.Visible = false; } else { if (myExpandCollapseButton != null) { myExpandCollapseButton.Style.Remove("visibility"); } } if (nestedView.HasDetailTables) { this.HideExpandColumnRecursive(nestedView); } } } }
private void DeleteBudgetRows_ToCompletion() { GridTableView grdTableVw = grdFollowUpBudget.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; foreach (GridItem gridItem in itemCollection) { if (!(gridItem is GridEditableItem)) { continue; } GridEditableItem item = gridItem as GridEditableItem; CheckBox chkSelected = item["SelectBudgetCol"].FindControl("chkDeleteCol") as CheckBox; if (chkSelected == null) { continue; } if (!chkSelected.Checked) { continue; } int idAssociate = ApplicationConstants.INT_NULL_VALUE; int.TryParse(item["IdAssociate"].Text, out idAssociate); FollowUpCompletionBudget followUpCompletionBudget = new FollowUpCompletionBudget(SessionManager.GetSessionValueNoRedirect(this.Page, SessionStrings.CONNECTION_MANAGER)); followUpCompletionBudget.DeleteBudgetRows(currentProject.Id, idAssociate, ReturnBudgetVersionFromCombo()); } }
protected void gridMain_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e) { if (e.DetailTableView.Name == "FormulaDetails") { GridTableView detailtabl = (GridTableView)e.DetailTableView; int recSkip = detailtabl.CurrentPageIndex * gridMain.PageSize; int recTake = detailtabl.PageSize; GridDataItem parentItem = (GridDataItem)detailtabl.ParentItem; int salesID = int.Parse(parentItem.GetDataKeyValue("ID").ToString()); JobFormulasController cont = new JobFormulasController(); detailtabl.VirtualItemCount = cont.CountJobFormulas(salesID); detailtabl.DataSource = cont.GetJobFormulas(salesID, recSkip, recTake); } else if (e.DetailTableView.Name == "CancelDetails") { GridTableView detailtabl = (GridTableView)e.DetailTableView; int recSkip = detailtabl.CurrentPageIndex * gridMain.PageSize; int recTake = detailtabl.PageSize; GridDataItem parentItem = (GridDataItem)detailtabl.ParentItem; int salesID = int.Parse(parentItem.GetDataKeyValue("ID").ToString()); JobCancelPricesController cont = new JobCancelPricesController(); detailtabl.VirtualItemCount = cont.CountJobCancelPrices(salesID); detailtabl.DataSource = cont.GetJobCancelPrices(salesID, recSkip, recTake); } }
private void GetSelectedCheckboxes() { GridTableView grdTableVw = grdFollowUpBudget.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; Dictionary <int, bool> selectedItems = new Dictionary <int, bool>(); foreach (GridItem gridItem in itemCollection) { if (!(gridItem is GridEditableItem)) { continue; } GridEditableItem item = gridItem as GridEditableItem; //CheckBox chkSelected = item["SelectWPCol"].FindControl("chkWPCol") as CheckBox; CheckBox chkSelected = item["SelectBudgetCol"].FindControl("chkDeleteCol") as CheckBox; if (chkSelected == null) { continue; } if (!chkSelected.Checked) { continue; } int idAssociate = ApplicationConstants.INT_NULL_VALUE; if (int.TryParse(item["IdAssociate"].Text, out idAssociate)) { selectedItems.Add(idAssociate, true); } } SessionManager.SetSessionValue(this, SELECTED_ITEMS, selectedItems); }
private void ApplyStyleSheetsForExport(GridTableView gridTableView) { if (null != gridTableView.GetItems(GridItemType.Header) && gridTableView.GetItems(GridItemType.Header).Count() > 0) { GridItem headerItem = gridTableView.GetItems(GridItemType.Header)[0]; headerItem.Style["font-size"] = "8pt"; headerItem.Style["color"] = "black"; headerItem.Style["vertical-align"] = "middle"; headerItem.Style["width"] = "80px"; foreach (TableCell tableCell in headerItem.Cells) { tableCell.Wrap = true; tableCell.Style["text-align"] = "center"; tableCell.Style["font-weight"] = "bold"; tableCell.Style["font-size"] = "12pt"; tableCell.Style["width"] = "75px"; } GridItem[] items = gridTableView.GetItems(GridItemType.Item); GridItem[] alternatingItems = gridTableView.GetItems(GridItemType.AlternatingItem); ApplyGridItemStyle(items); ApplyGridItemStyle(alternatingItems); } }
/// <summary> /// Selects the items which have been previously selected /// </summary> /// <param name="collection"></param> /// <param name="items"></param> /// <param name="callback"></param> private void SelectItems(HashSet <string> collection, GridDataItemCollection items, Action <GridDataItem> callback) { GridDataItem currentDataItem; for (int i = 0; i < items.Count; i++) { currentDataItem = items[i]; //Generates the unique identifier for the item string uniqueIdentifier = GenerateUniqueIdentifier(currentDataItem); //Checks if the item was previously selected if (collection.Contains(uniqueIdentifier)) { (currentDataItem.FindControl(CheckBoxId) as CheckBox).Checked = true; currentDataItem.Selected = true; } if (callback != null) { callback.Invoke(currentDataItem); } if (currentDataItem.ChildItem != null) { // If the item has a nested table view selects the child items bool expanded = currentDataItem.Expanded; currentDataItem.Expanded = true; GridTableView ownerTableView = currentDataItem.ChildItem.NestedTableViews[0]; string ownerTableViewDataKeyName = ownerTableView.DataKeyNames[0]; this.SelectItems(TableViews[ownerTableView.Name], ownerTableView.Items, callback); //Returns the previous expanded state currentDataItem.Expanded = expanded; } } }
protected void btnSaveAssetTypeChanges_Click(object sender, EventArgs e) { foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); foreach (GridDataItem assetTypeItem in tableView.Items) { Hashtable assetTypeValues = new Hashtable(); assetTypeItem.ExtractValues(assetTypeValues); int assetTypeId = Convert.ToInt32(assetTypeValues["AssetTypeId"].ToString()); AssetTypeEntity assetType = new AssetTypeEntity(assetTypeId); TextBox txtName = assetTypeItem.FindControl("txtName") as TextBox; TextBox txtAssetTypeDescription = assetTypeItem.FindControl("txtAssetTypeDescription") as TextBox; TextBox txtSpanishLabel = assetTypeItem.FindControl("txtSpanishLabel") as TextBox; DropDownList ddlAssetTypeCategory = assetTypeItem.FindControl("ddlAssetTypeCategory") as DropDownList; assetType.Name = txtName.Text.Trim().Length > 0 ? txtName.Text.Trim() : ""; assetType.Description = txtAssetTypeDescription.Text.Trim().Length > 0 ? txtAssetTypeDescription.Text.Trim() : ""; assetType.SpanishLabel = txtSpanishLabel.Text.Trim().Length > 0 ? txtSpanishLabel.Text.Trim() : ""; assetType.AssetCategoryId = Convert.ToInt32(ddlAssetTypeCategory.SelectedValue); assetType.Save(); } } } }
/// <summary> /// According to the ckeck state of the master checkbox selects or deselects the items down in the hierarchy /// </summary> /// <param name="tableView"></param> /// <param name="shouldCheck"></param> protected void CheckItemsInTableView(GridTableView tableView, bool shouldCheck) { int currentPageSize = tableView.PageSize; int currentPageIndex = tableView.CurrentPageIndex; //Resizing the table view in order to increase the performance tableView.PageSize = int.MaxValue; tableView.Rebind(); foreach (GridDataItem detailItem in tableView.Items) { detailItem.Selected = shouldCheck; (detailItem[CheckBoxTemplateColumnUniqueName].FindControl(CheckBoxId) as CheckBox).Checked = shouldCheck; GridTableView ownerTableView = detailItem.OwnerTableView; //Generates a unique identifier for the data item. This is done in order to distinguish every data item in the grid string dataKeyValue = GenerateUniqueIdentifier(detailItem); //Select or deselect the items in the current TableView this.SetCollectionValue(TableViews[ownerTableView.Name], dataKeyValue, shouldCheck); detailItem.Expanded = true; //If there is next level of hierarchy exist select or deselectes the items in it if (detailItem.ChildItem != null) { CheckItemsInTableView(detailItem.ChildItem.NestedTableViews[0], shouldCheck); } } tableView.PageSize = currentPageSize; tableView.CurrentPageIndex = currentPageIndex; tableView.Rebind(); }
/// <summary> /// Checks if the given dataItem has detail-most child items (i.e.: if a phase has any cc's or if a wp has any cc's) /// </summary> /// <param name="dataItem"></param> /// <returns></returns> private bool HasDetailMostChildItems(GridDataItem dataItem) { GridTableView ownerTableView = dataItem.OwnerTableView; if (ownerTableView.Name == MasterTableView.DetailTables[0].DetailTables[0].Name) { return(false); } int idPhase = int.Parse(dataItem["IdPhase"].Text); DataTable tblChild = (DataTable)MasterTableView.DetailTables[0].DetailTables[0].DataSource; //If for some reason (the way the internal mechanism of radgrid works) the underlying dataTable in null, we return //true, meaning that for the given item, no action (hiding the expand/collapse item) will be taken. This has been tested //and it works in every situation if (tblChild == null) { return(true); } foreach (DataRow row in tblChild.Rows) { if ((int)row["IdPhase"] == idPhase) { return(true); } } return(false); }
private void CopyBudgetRows_Revised() { GridTableView grdTableVw = grdCopyBudget.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; foreach (GridItem gridItem in itemCollection) { if (!(gridItem is GridEditableItem)) { continue; } GridEditableItem item = gridItem as GridEditableItem; CheckBox chkSelected = item["SelectAssociateCol"].FindControl("chkSelectAssociate") as CheckBox; if (chkSelected == null) { continue; } if (!chkSelected.Checked) { continue; } int idAssociateNM = ApplicationConstants.INT_NULL_VALUE; int.TryParse(item["IdAssociate"].Text, out idAssociateNM); FollowUpRevisedBudget followUpRevisedBudget = new FollowUpRevisedBudget(SessionManager.GetSessionValueNoRedirect(this.Page, SessionStrings.CONNECTION_MANAGER)); followUpRevisedBudget.CopyRevisedBudget(currentProject.Id, GetIdAssociateLM(), idAssociateNM); } }
protected void RadGridPublicationChannels_BatchEditCommand(object sender, Telerik.Web.UI.GridBatchEditingEventArgs e) { GridTableView masterTable = (sender as RadGrid).MasterTableView; GridDataItem dataItems = masterTable.Items[2]; TableCell cell = dataItems["Use"]; //RadDropDownList triggerEditor = masterTable.GetBatchColumnEditor("TriggerIDDropDown") as RadDropDownList; // int n = triggerEditor.SelectedIndex; foreach (GridBatchEditingCommand command in e.Commands) { GridDataItem itm = command.Item; Hashtable newValues = command.NewValues; Hashtable oldValues = command.OldValues; /* foreach (string key in command.NewValues.Keys) * { * if (newValues[key] != oldValues[key]) //You may want to implement stronger difference checks here, or a check for the command name (e.g., when inserting there is little point in looking up old values * { * string output = String.Format("column: {0} with new value {1}<br />", key, command.NewValues[key]); * Response.Write(output); * } * }*/ //a simple way of getting the value of a column whose name you know string channelName = newValues["ChannelName"].ToString(); string newUse = newValues["Use"].ToString(); string newTrigger = newValues["_Trigger"].ToString(); string pubDateMoveDays = newValues["PubDateMoveDays"].ToString(); string releaseDelay = newValues["ReleaseDelay"].ToString(); } }
// function for export setting protected void GridTableHierarchySetEditability(GridTableView view, bool editAllowed) { foreach (GridFilteringItem item in view.GetItems(GridItemType.FilteringItem)) { item.Visible = false; } foreach (GridHeaderItem item in view.GetItems(GridItemType.Header)) { if (item.Cells[0].Text == " ") { item.Cells[0].Visible = false; } } //If editing is not allowed, remove any edit or command-button columns. if (editAllowed) { //Remove editing columns in the current view foreach (GridColumn column in view.Columns) { if (column.UniqueName == "ExpandColumn") { column.Display = false; column.Visible = false; } if (column.UniqueName == "DeletePaycode" || column.UniqueName == "EditPaycod") { column.Display = false; column.Visible = false; } if (column.UniqueName == "EditCitizen" || column.UniqueName == "DeleteCitizen") { column.Display = false; column.Visible = false; } if (column.UniqueName == "EditExpat" || column.UniqueName == "DeleteExpat") { column.Display = false; column.Visible = false; } } } if (view.HasDetailTables) { foreach (GridDataItem item in view.Items) { if (item.HasChildItems) { foreach (GridTableView innerView in item.ChildItem.NestedTableViews) { GridTableHierarchySetEditability(innerView, true); } } } } }
/// <summary> /// Checks whether the given dataItem has child items by searching in the underlying datasource /// </summary> /// <param name="dataItem">the dataitem whose child items are searched for</param> /// <returns>true if the given dataItem has child items, false otherwise</returns> private bool HasChildItems(GridDataItem dataItem) { GridTableView ownerTableView = dataItem.OwnerTableView; if (ownerTableView.Name == this.MasterTableView.DetailTables[0].DetailTables[0].Name) { return(false); } //Holds the values of the master item which will be searched for in the detail table List <int> masterValues = new List <int>(); //Holds the keys in the detail table which will be searched for the master values List <string> detailKeys = new List <string>(); //Populate the masterValues and detailKeys lists for (int i = 0; i < ownerTableView.DetailTables[0].ParentTableRelation.Count; i++) { masterValues.Add(int.Parse(dataItem[ownerTableView.DetailTables[0].ParentTableRelation[i].MasterKeyField].Text)); detailKeys.Add(ownerTableView.DetailTables[0].ParentTableRelation[i].DetailKeyField); } //Gets the datatable of the child elements of nestedViewItem in which we will search for child elements of nestedViewItem DataTable tblChild = (DataTable)ownerTableView.DetailTables[0].DataSource; //If for some reason (the way the internal mechanism of radgrid works) the underlying dataTable in null, we return //true, meaning that for the given item, no action (hiding the expand/collapse item) will be taken. This has been tested //and it works in every situation if (tblChild == null) { return(true); } bool found = false; //Search through the rows in the underlying datatable for the keys in the detail table whose values must match those //in masterValues foreach (DataRow row in tblChild.Rows) { found = true; for (int i = 0; i < masterValues.Count; i++) { //If there is at least one key that does not have the master value, go to the next row if ((int)row[detailKeys[i]] != masterValues[i]) { found = false; break; } } //If at least one detail row was found in the detail table, break from the foreach loop if (found) { break; } } return(found); }
//Selects the items down in the hierarchy private void SelectChildTableItems(GridDataItem dataItem) { dataItem.Expanded = ExpandedRows.Contains(dataItem.GetDataKeyValue(dataItem.OwnerTableView.DataKeyNames[0]).ToString()); //If the item is expanded selects the child items if it is not the expanded the items should not be selected if (dataItem.Expanded) { GridTableView nestedTableView = dataItem.ChildItem.NestedTableViews[0]; this.SelectItems(TableViews[nestedTableView.Name], nestedTableView.Items, null); } }
/// <summary> /// Event handler for the Click event of btnSave /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMoveBudget_Click(object sender, EventArgs e) { try { int idAssociateNM = ApplicationConstants.INT_NULL_VALUE; string BudgetCode = GetBudgetCode(); switch (BudgetCode) { case ApplicationConstants.MODULE_REVISED: MoveBudgetRows_Revised(); break; case ApplicationConstants.MODULE_REFORECAST: MoveBudgetRows_ToCompletion(); break; default: throw new NotImplementedException(ApplicationMessages.EXCEPTION_NOT_IMPLEMENTED); } GridTableView grdTableVw = grdMoveBudget.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; string associateNameTo = null; foreach (GridDataItem gridItem in itemCollection) { associateNameTo = gridItem["Associate"].Text; idAssociateNM = GetIdAssociateNM(gridItem); if (idAssociateNM == ApplicationConstants.INT_NULL_VALUE) { continue; } else { break; } } lblMoveBudgetStatus.Text = "Budget successfully moved from " + hdnAssociateName.Value + " to " + associateNameTo; } catch (IndException indExc) { HideChildControls(); ShowError(indExc); return; } catch (Exception exc) { HideChildControls(); ShowError(new IndException(exc)); return; } }
protected void gridMain_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e) { GridTableView detailtabl = e.DetailTableView; int recSkip = detailtabl.CurrentPageIndex * gridMain.PageSize; int recTake = detailtabl.PageSize; GridDataItem parentItem = detailtabl.ParentItem; int customerID = int.Parse(parentItem.GetDataKeyValue("ID").ToString()); FilesController cont = new FilesController(); detailtabl.VirtualItemCount = cont.CountFilesByCustomerID(customerID); detailtabl.DataSource = cont.GetFilesByCustomerID(customerID, recSkip, recTake); }
public void HideExpandColumnRecursive(GridTableView tableView) { GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { nestedView.ParentItem.Expanded = true; HideExpandColumnRecursive(nestedView); } } }
protected void gridMain_InsertCommand(object source, GridCommandEventArgs e) { if (e.Item.OwnerTableView.Name == "Master") { var editableItem = ((GridEditableItem)e.Item); using (var dbContext = new OTERTConnStr()) { var curSale = new Sales(); Hashtable values = new Hashtable(); editableItem.ExtractValues(values); if (Session["SalesType"] != null) { SalesType = int.Parse(Session["SalesType"].ToString()); } if (SalesType > 0) { try { curSale.Name = (string)values["Name"]; curSale.Type = SalesType; dbContext.Sales.Add(curSale); dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } finally { SalesType = -1; Session.Remove("SalesType"); } } else { ShowErrorMessage(-1); } } } else if (e.Item.OwnerTableView.Name == "Details") { GridTableView detailtabl = (GridTableView)e.Item.OwnerTableView; GridDataItem parentItem = (GridDataItem)detailtabl.ParentItem; int salesID = int.Parse(parentItem.GetDataKeyValue("ID").ToString()); var editableItem = ((GridEditableItem)e.Item); using (var dbContext = new OTERTConnStr()) { var curSaleFurmula = new SalesFormulas(); Hashtable values = new Hashtable(); editableItem.ExtractValues(values); curSaleFurmula.SalesID = salesID; curSaleFurmula.Distance = decimal.Parse((string)values["Distance"]); curSaleFurmula.SalePercent = decimal.Parse((string)values["SalePercent"]); dbContext.SalesFormulas.Add(curSaleFurmula); try { dbContext.SaveChanges(); } catch (Exception) { ShowErrorMessage(-1); } } } }
public void HideExpandColumnRecursive(GridTableView tableView) { thisUserPermissions.AddRange(KVSCommon.Database.User.GetAllPermissionsByID((Int32.Parse(Session["CurrentUserId"].ToString())))); GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { nestedView.ParentItem.Expanded = true; HideExpandColumnRecursive(nestedView); } } }
private void ClearOtherDefaults(GridItem gi) { GridTableView gtv = gi.OwnerTableView; foreach (GridItem tableviewitem in gtv.Items) { LinkButton lb = tableviewitem.FindControl <LinkButton>("cmdDefaultProductVariant"); if (lb != null) { lb.Text = AppLogic.GetString("admin.productvariant.makedefault", ThisCustomer.LocaleSetting); lb.Enabled = true; } } }
protected void btnSaveAssetTypePrices_Click(object sender, EventArgs e) { foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); foreach (GridDataItem assetTypeItem in tableView.Items) { Hashtable assetTypeValues = new Hashtable(); assetTypeItem.ExtractValues(assetTypeValues); int serviceLocationAssetTypeId = Convert.ToInt32(assetTypeValues["ServiceLocationAssetTypeId"].ToString()); ServiceLocationAssetTypeEntity serviceLocationAssetType = new ServiceLocationAssetTypeEntity(serviceLocationAssetTypeId); TextBox txtPricePerUnit = assetTypeItem.FindControl("txtPricePerUnit") as TextBox; HiddenField hdnOrigPrice = assetTypeItem.FindControl("hdnOrigPrice") as HiddenField; decimal price = 0; decimal origPrice = Convert.ToDecimal(hdnOrigPrice.Value.Trim().Replace("$", "")); if (txtPricePerUnit.Text.Trim().Length > 0) { price = Convert.ToDecimal(txtPricePerUnit.Text.Trim().Replace("$", "")); } serviceLocationAssetType.PricePerUnit = price; serviceLocationAssetType.Save(); if (price != origPrice) { ChangeLogEntity cle = new ChangeLogEntity(); cle.UserId = sm.AuthenticatedUser.UserId; cle.ChangeDate = DateTime.Now; cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.AssetTypePriceChange; cle.Save(); ServiceLocationAssetTypeChangeLogEntity slatcle = new ServiceLocationAssetTypeChangeLogEntity(); slatcle.ServiceLocationAssetTypeId = serviceLocationAssetType.ServiceLocationAssetTypeId; slatcle.ChangeLog = cle; slatcle.Save(); } } } } messages.AddSuccessDiv("Asset types successfully saved"); }
private void SaveAssignments() { foreach (GridDataItem item in rdAccountGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)item.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); if (tableView.Name == "WeekView") { foreach (GridDataItem childItem in tableView.Items) { Hashtable values = new Hashtable(); childItem.ExtractValues(values); int aeaeId = Convert.ToInt32(values["AccountEmployeeAssignmentId"].ToString()); AccountEmployeeAssignmentEntity acctEmployeeAssgnmnt = new AccountEmployeeAssignmentEntity(aeaeId); if (acctEmployeeAssgnmnt != null) { List <string> days = new List <string>() { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; foreach (string day in days) { DropDownList ddlEmployees = childItem.FindControl("ddlEmployees" + day) as DropDownList; if (ddlEmployees.SelectedValue != "") { acctEmployeeAssgnmnt.GetFieldByName(day).CurrentValue = Convert.ToInt32(ddlEmployees.SelectedValue); } else { acctEmployeeAssgnmnt.GetFieldByName(day).CurrentValue = null; } } acctEmployeeAssgnmnt.IsDirty = true; acctEmployeeAssgnmnt.Save(); } } } } } }
private void MoveBudgetRows_Revised() { GridTableView grdTableVw = grdMoveBudget.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; foreach (GridItem gridItem in itemCollection) { int idAssociateNM = GetIdAssociateNM(gridItem); if (idAssociateNM != ApplicationConstants.INT_NULL_VALUE) { FollowUpRevisedBudget followUpRevisedBudget = new FollowUpRevisedBudget(SessionManager.GetSessionValueNoRedirect(this.Page, SessionStrings.CONNECTION_MANAGER)); followUpRevisedBudget.MoveRevisedBudget(currentProject.Id, GetIdAssociateLM(), idAssociateNM, SessionManager.GetCurrentUser(this).IdAssociate); btnMoveBudget.Visible = false; } } }
protected void ddlEmployees_OnSelectedIndexChanged(object sender, EventArgs e) { DropDownList ddlEmployees = sender as DropDownList; string selectedEmployeeId = ddlEmployees.SelectedValue; // header dropdowns are named "ddlEmployeesHeader[NameOfDay]", we want just the day string day = ddlEmployees.ID.Substring(18); Control xx = ddlEmployees.Parent; GridTableView tableView = ddlEmployees.Parent.Parent.Parent.Parent.Parent as GridTableView; foreach (GridDataItem item in tableView.Items) { DropDownList ddlEmployee = item.FindControl("ddlEmployees" + day) as DropDownList; ddlEmployee.SelectedValue = selectedEmployeeId; } }
protected void btnCopyCoreTeam_Click(object sender, EventArgs e) { try { GridTableView grdTableVw = grdCopyCoreTeam.MasterTableView; GridDataItemCollection itemCollection = grdTableVw.Items; foreach (GridItem gridItem in itemCollection) { if (!(gridItem is GridEditableItem)) { continue; } GridEditableItem item = gridItem as GridEditableItem; CheckBox chkSelected = item["SelectProjectCol"].FindControl("chkSelectProject") as CheckBox; if (chkSelected == null) { continue; } if (!chkSelected.Checked) { continue; } int idTargetProject = ApplicationConstants.INT_NULL_VALUE; int.TryParse(item["IdProject"].Text, out idTargetProject); ProjectCopyCoreTeam copyCoreTeam = new ProjectCopyCoreTeam(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER)); copyCoreTeam.IdProject = currentProject.Id; copyCoreTeam.IdTargetProject = idTargetProject; int result = copyCoreTeam.CopyProjectCoreTeam(); } LoadGrid(); lblStatus.Text = "Core team successfully copied"; } catch (IndException ex) { ShowError(ex); return; } catch (Exception ex) { ShowError(new IndException(ex)); return; } }
// export formating functions void HideCommandColumns(GridTableView gridTableView) { foreach (GridNestedViewItem nestedViewItem in gridTableView.GetItems(GridItemType.NestedView)) { if (nestedViewItem.NestedTableViews.Length > 0) { foreach (GridColumn column in gridTableView.Columns) { if (column.UniqueName == "EditHolidays" || column.UniqueName == "DeleteHolidays") { column.Display = false; column.Visible = false; } } HideCommandColumns(nestedViewItem.NestedTableViews[0]); } } }
/// <summary> /// Handles the check of the an item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DetailCheckbox_CheckedChanged(object sender, EventArgs e) { //Check or uncheck the item CheckBox box = (CheckBox)sender; GridDataItem dataItem = (GridDataItem)box.NamingContainer; dataItem.Selected = box.Checked; bool shouldCheckOwner = true; //Gets a unique value for the grid item string uniqueIdentifier = GenerateUniqueIdentifier(dataItem); this.SetCollectionValue(TableViews[dataItem.OwnerTableView.Name], uniqueIdentifier, box.Checked); //If the current data items has child items check or unchecks all child items if (dataItem.HasChildItems) { bool dataItemExpandedState = dataItem.Expanded; dataItem.Expanded = true; CheckItemsInTableView(dataItem.ChildItem.NestedTableViews[0], box.Checked); dataItem.Expanded = dataItemExpandedState; } //Moving up in the hierarchy and determining whether to check the master items while (dataItem.OwnerTableView.ParentItem != null) { GridTableView ownerTableView = dataItem.OwnerTableView; //Checking if the owner should be selected shouldCheckOwner = ShouldCheckMasterItem(ownerTableView); GridDataItem parentItem = ownerTableView.ParentItem; string ownerTableName = parentItem.OwnerTableView.Name; //Extracting the unique signature of the parent item string currentOwner = GenerateUniqueIdentifier(ownerTableView.ParentItem); //Selecteing or deselecting the owner this.SetCollectionValue(TableViews[ownerTableName], currentOwner, shouldCheckOwner); (parentItem[CheckBoxTemplateColumnUniqueName].FindControl(CheckBoxId) as CheckBox).Checked = shouldCheckOwner; parentItem.Selected = shouldCheckOwner; //Getting a reference to a data item in an upper level of the grid dataItem = parentItem; } }
/// <summary> /// Localizes the given <see cref="GridTableView"/> within the <see cref="JobsGrid"/>. /// </summary> /// <param name="tableView">The table view.</param> private void LocalizeGridTable(GridTableView tableView) { tableView.PagerStyle.FirstPageToolTip = this.Localize("First Page.ToolTip"); tableView.PagerStyle.PrevPageToolTip = this.Localize("Previous Page.ToolTip"); tableView.PagerStyle.NextPageToolTip = this.Localize("Next Page.ToolTip"); tableView.PagerStyle.LastPageToolTip = this.Localize("Last Page.ToolTip"); tableView.PagerStyle.FirstPageText = this.Localize("First Page.Text"); tableView.PagerStyle.PrevPageText = this.Localize("Previous Page.Text"); tableView.PagerStyle.NextPageText = this.Localize("Next Page.Text"); tableView.PagerStyle.LastPageText = this.Localize("Last Page.Text"); tableView.PagerStyle.PagerTextFormat = this.Localize("Pager.Format"); tableView.CommandItemSettings.ExportToExcelText = this.Localize("Export To Excel.ToolTip"); tableView.CommandItemSettings.ExportToCsvText = this.Localize("Export To CSV.ToolTip"); foreach (GridColumn column in tableView.Columns) { column.HeaderText = this.Localize(column.HeaderText); } }
protected void Page_Init(object sender, EventArgs e) { if (TableViews.Count == 0) { //On initial load create items in the dictionary that correspond to the GridTableViewNames Dictionary <string, HashSet <string> > dict = new Dictionary <string, HashSet <string> >(); GridTableView tableView = RadGrid1.MasterTableView; while (tableView.DetailTables.Count != 0) { dict.Add(tableView.Name, new HashSet <string>()); if (tableView.DetailTables.Count > 0) { tableView = tableView.DetailTables[0]; } } dict.Add(tableView.Name, new HashSet <string>()); TableViews = dict; } }
private void toggleExpansionRecursive(GridTableView parentView, bool expandValue, bool reload = false) { //bool showEditFields = ShowEditFields(); GridItem[] childViewItems = parentView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem childView in childViewItems) { foreach (GridTableView nestedView in childView.NestedTableViews) { // nestedView.ParentItem.ItemIndexHierarchical GridDataItem item = nestedView.ParentItem as GridDataItem; string keyName = item.GetDataKeyValue("TagName").ToString(); if (reload || !Page.IsPostBack) { // on new load -- store in expandedStates this.ExpandedStates[keyName] = expandValue; } else { // after initial load -- storage in expandedStates is handled by ItemCommand // set expandValue from expandedStates expandValue = this.ExpandedStates[keyName] != null && (bool)this.ExpandedStates[keyName]; } // GridColumn dragcolumn = nestedView.Columns.FindByUniqueName("DragResponse") ; //if ((base.ShowEditFields(enumDocumentType.JQ)) && (base.HasHRGroupPermission)) //{ // if (dragcolumn!=null) // {dragcolumn.Visible =true;} //} //else //{ // if (dragcolumn != null) // { dragcolumn.Visible = false; } //} nestedView.ParentItem.Expanded = expandValue; toggleExpansionRecursive(nestedView, expandValue); } } }
public void HideExpandColumnRecursive(GridTableView tableView) { GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { if (nestedView.Items.Count == 0) { TableCell cell = nestedView.ParentItem["ExpandColumn"]; cell.Controls[0].Visible = false; nestedViewItem.Visible = false; } if (nestedView.HasDetailTables) { HideExpandColumnRecursive(nestedView); } } } }
/// <summary> /// Checking if all the items in the GridTableView are checked in order to determine whether to check the master item /// </summary> /// <param name="nestedTableView"></param> /// <returns></returns> protected bool ShouldCheckMasterItem(GridTableView nestedTableView) { bool isChecked = true; int currentPageSize = nestedTableView.PageSize; int currentPageIndex = nestedTableView.CurrentPageIndex; //Resizing the table view in order to increase the performance nestedTableView.PageSize = int.MaxValue; nestedTableView.Rebind(); foreach (GridDataItem detailItem in nestedTableView.Items) { string currentDataItem = GenerateUniqueIdentifier(detailItem); if (!TableViews[nestedTableView.Name].Contains(currentDataItem)) { isChecked = false; break; } } nestedTableView.PageSize = currentPageSize; nestedTableView.CurrentPageIndex = currentPageIndex; nestedTableView.Rebind(); return isChecked; }
/// <summary> /// According to the ckeck state of the master checkbox selects or deselects the items down in the hierarchy /// </summary> /// <param name="tableView"></param> /// <param name="shouldCheck"></param> protected void CheckItemsInTableView(GridTableView tableView, bool shouldCheck) { int currentPageSize = tableView.PageSize; int currentPageIndex = tableView.CurrentPageIndex; //Resizing the table view in order to increase the performance tableView.PageSize = int.MaxValue; tableView.Rebind(); foreach (GridDataItem detailItem in tableView.Items) { detailItem.Selected = shouldCheck; (detailItem[CheckBoxTemplateColumnUniqueName].FindControl(CheckBoxId) as CheckBox).Checked = shouldCheck; GridTableView ownerTableView = detailItem.OwnerTableView; //Generates a unique identifier for the data item. This is done in order to distinguish every data item in the grid string dataKeyValue = GenerateUniqueIdentifier(detailItem); //Select or deselect the items in the current TableView this.SetCollectionValue(TableViews[ownerTableView.Name], dataKeyValue, shouldCheck); detailItem.Expanded = true; //If there is next level of hierarchy exist select or deselectes the items in it if (detailItem.ChildItem != null) { CheckItemsInTableView(detailItem.ChildItem.NestedTableViews[0], shouldCheck); } } tableView.PageSize = currentPageSize; tableView.CurrentPageIndex = currentPageIndex; tableView.Rebind(); }
public DnnGridItem(GridTableView ownerTableView, int itemIndex, int dataSetIndex, GridItemType itemType) : base(ownerTableView, itemIndex, dataSetIndex, itemType) { }
/// <summary> /// Localizes the given <see cref="GridTableView"/> within the <see cref="JobsGrid"/>. /// </summary> /// <param name="tableView">The table view.</param> private void LocalizeGridTable(GridTableView tableView) { tableView.PagerStyle.FirstPageToolTip = this.Localize("First Page.ToolTip"); tableView.PagerStyle.PrevPageToolTip = this.Localize("Previous Page.ToolTip"); tableView.PagerStyle.NextPageToolTip = this.Localize("Next Page.ToolTip"); tableView.PagerStyle.LastPageToolTip = this.Localize("Last Page.ToolTip"); tableView.PagerStyle.FirstPageText = this.Localize("First Page.Text"); tableView.PagerStyle.PrevPageText = this.Localize("Previous Page.Text"); tableView.PagerStyle.NextPageText = this.Localize("Next Page.Text"); tableView.PagerStyle.LastPageText = this.Localize("Last Page.Text"); tableView.PagerStyle.PagerTextFormat = this.Localize("Pager.Format"); tableView.CommandItemSettings.ExportToExcelText = this.Localize("Export To Excel.ToolTip"); tableView.CommandItemSettings.ExportToCsvText = this.Localize("Export To CSV.ToolTip"); foreach (GridColumn column in tableView.Columns) { column.HeaderText = this.Localize(column.HeaderText); } }
private void LocalizeDetailGridTable(GridTableView detailTableView) { this.LocalizeGridTable(detailTableView); detailTableView.PagerStyle.PagerTextFormat = this.Localize("DetailPager.Format"); }
public DnnGridHeaderItem(GridTableView ownerTableView, int itemIndex, int dataSetIndex) : base(ownerTableView, itemIndex, dataSetIndex) { }