// end of method private void SortListByDisplayName(Hashtable selectedHashList, ListReportView wp) { wp.ViewLists = string.Empty; if (selectedHashList != null && selectedHashList.Count > 0) { var result = new List <DictionaryEntry>(selectedHashList.Count); foreach (DictionaryEntry entry in selectedHashList) { result.Add(entry); } result.Sort((x, y) => { IComparable comparable = x.Value as IComparable; if (comparable != null) { return(comparable.CompareTo(y.Value)); } return(0); }); foreach (DictionaryEntry entry in result) { // Console.WriteLine(entry.Key.ToString() + ":" + entry.Value.ToString()); wp.ViewLists += "|" + entry.Key.ToString(); } if (wp.ViewLists.Length > 0 && wp.ViewLists.IndexOf("|", 0) >= 0) { wp.ViewLists = wp.ViewLists.Remove(0, 1); } wp.ViewLists += "|" + "Report Library"; } }
// end of method private void PopulateDisplayNames(ListReportView wp, ref SPGridView grv) { if (!string.IsNullOrEmpty(wp.DisplayListNames)) { _hashedNames = wp.GetListNamesInHashtable(wp.DisplayListNames); } if (!string.IsNullOrEmpty(wp.SelectedListNames)) { _selectedHashNames = wp.GetListNamesInHashtable(wp.SelectedListNames); } for (int idx = 0; idx < grv.Rows.Count; idx++) { CheckBox selectCtl = (CheckBox)grv.Rows[idx].FindControl("selectedList"); TextBox txtBox = (TextBox)grv.Rows[idx].FindControl("selectDisplayName"); HtmlInputHidden listHiddenName = (HtmlInputHidden)grv.Rows[idx].FindControl("listIdItem"); if (_selectedHashNames != null && _selectedHashNames.Count > 0) { if (_selectedHashNames.ContainsKey(listHiddenName.Value.ToString())) { selectCtl.Checked = true; } } string sDisplayName = listHiddenName.Value.ToString(); if (_hashedNames != null && _hashedNames.Count > 0) { if (_hashedNames.ContainsKey(sDisplayName)) { sDisplayName = _hashedNames[sDisplayName].ToString(); } } txtBox.Text = sDisplayName; } }
// end of method private void StoreSortListByDisplayName(ListReportView wp, SPGridView grv) { wp.DisplayListNames = string.Empty; wp.SelectedListNames = string.Empty; try { for (int idx = 0; idx < grv.Rows.Count; idx++) { CheckBox selectCtl = (CheckBox)grv.Rows[idx].FindControl("selectedList"); TextBox txtBox = (TextBox)grv.Rows[idx].FindControl("selectDisplayName"); HtmlInputHidden listHiddenName = (HtmlInputHidden)grv.Rows[idx].FindControl("listIdItem"); string sDisplayName = txtBox.Text; foreach (string name in txtBox.Text.Split(',')) { sDisplayName = name; break; } wp.DisplayListNames += listHiddenName.Value.ToString() + "::" + sDisplayName + "|"; if (selectCtl.Checked) { wp.SelectedListNames += listHiddenName.Value.ToString() + "::" + sDisplayName + "|"; } } //remove last | character int lastPos = wp.DisplayListNames.LastIndexOf("|"); if (lastPos > -1) { wp.DisplayListNames = wp.DisplayListNames.Remove(lastPos, 1); } lastPos = string.IsNullOrEmpty(wp.SelectedListNames) ? -1 : wp.SelectedListNames.LastIndexOf("|"); if (lastPos > -1) { wp.SelectedListNames = wp.SelectedListNames.Remove(lastPos, 1); } } catch { wp.DisplayListNames = string.Empty; wp.SelectedListNames = string.Empty; } }
public override void ApplyChanges() { ToolPane tp = this.ParentToolPane; ListReportView myWP = (ListReportView)tp.SelectedWebPart; var gridviewwithcheckbox = (SPGridView)this.FindControl("mySPGridViewControl"); //string newVal = Page.Request["reportViewLists"]; //if (!string.IsNullOrEmpty(newVal.Trim())) //{ // newVal = newVal.Replace("\r\n", "|"); //} //myWP.ViewLists = newVal; bool result = false; bool.TryParse(Page.Request["cbExpandView"], out result); myWP.ExpandView = result; StoreSortListByDisplayName(myWP, gridviewwithcheckbox); _selectedHashNames = myWP.GetListNamesInHashtable(myWP.SelectedListNames); SortListByDisplayName(_selectedHashNames, myWP); }
protected override void RenderToolPart(HtmlTextWriter output) { base.RenderToolPart(output); ToolPane tp = this.ParentToolPane; ListReportView myWP = (ListReportView)tp.SelectedWebPart; //output.Write("<div>"); output.Write("<div class=\"UserSectionTitle\">"); output.Write("<table style=\"PADDING-LEFT: 5px\" cellPadding=\"1\">"); output.Write("<tbody>"); output.Write("<tr>"); //output.Write("<td>List(s)<br/>"); //output.Write("<textarea class=\"ms-input\" rows=\"5\" cols=\"25\" name=\"reportViewLists\">" + // ((!string.IsNullOrEmpty(myWP.ViewLists)) ? myWP.ViewLists.Replace("|", "\r\n") : string.Empty) + // "</textarea>"); //output.Write("</td>"); //output.Write("</tr>"); //output.Write("<tr>"); output.Write("<td>"); if (myWP.ExpandView) { output.Write("<input type=\"checkbox\" name=\"cbExpandView\" checked=\"checked\" value=\"true\" />Expand View"); } else { output.Write("<input type=\"checkbox\" name=\"cbExpandView\" value=\"true\" />Expand View"); } output.Write("</td>"); output.Write("</tr>"); output.Write("</tbody>"); output.Write("</table>"); output.Write("</div>"); }