or
| <div style="width: 100%;"> |
| <Telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" |
| AllowSorting="True" ShowStatusBar="true" GridLines="None" ShowGroupPanel="True" > |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"> |
| <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" /> |
| <Scrolling AllowScroll="True" ScrollHeight='400px' UseStaticHeaders="True" SaveScrollPosition="True" /> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| <MasterTableView Width="100%" TableLayout='Fixed' AllowMultiColumnSorting="true"> |
| <ItemStyle Wrap='true' /> |
| <HeaderStyle Width='100px' /> |
| <AlternatingItemStyle Wrap='true' /> |
| </MasterTableView> |
| <SortingSettings SortedBackColor="Azure" /> |
| </Telerik:RadGrid> |
| </div> |
| private void CreateCustomControl(TableCell templateControl, Property property) |
| { |
| switch (property.UiType) |
| { |
| case "RadTextBox": |
| #region |
| RadTextBox radTextBox1 = new RadTextBox(); |
| radTextBox1.ID = string.Format("RadTextBox_{0}", property.Id); |
| if(!IsPostBack)radTextBox1.Text = property.DefaultValue; |
| if (property.MaxLength != null) |
| { |
| radTextBox1.MaxLength = (int)property.MaxLength; |
| } |
| templateControl.Controls.Add(radTextBox1); |
| #endregion |
| break; |
| case "MultilineRadTextBox": |
| #region |
| RadTextBox radTextBox2 = new RadTextBox(); |
| radTextBox2.ID = string.Format("MultilineRadTextBox_{0}", property.Id); |
| radTextBox2.TextMode = InputMode.MultiLine; |
| if (!IsPostBack) radTextBox2.Text = property.DefaultValue; |
| if (property.MaxLength != null) |
| { |
| radTextBox2.MaxLength = (int)property.MaxLength; |
| } |
| templateControl.Controls.Add(radTextBox2); |
| #endregion |
| break; |
| case "NumericTextBox": |
| #region |
| RadNumericTextBox radNumericTextBox = new RadNumericTextBox(); |
| radNumericTextBox.ID = string.Format("NumericTextBox_{0}", property.Id); |
| if (!IsPostBack) radNumericTextBox.Value = !string.IsNullOrEmpty(property.DefaultValue) ? double.Parse(property.DefaultValue) : (double)0; |
| radNumericTextBox.MaxValue = (double)property.MaxValue; |
| radNumericTextBox.MinValue = (double)property.MinValue; |
| templateControl.Controls.Add(radNumericTextBox); |
| #endregion |
| break; |
| case "RadDateInput": |
| #region |
| RadDateInput radDatePicker = new RadDateInput(); |
| radDatePicker.ID = string.Format("RadDateInput_{0}", property.Id); |
| radDatePicker.ReadOnly = true; |
| if (!string.IsNullOrEmpty(property.DefaultValue)) |
| { |
| if (!IsPostBack) radDatePicker.SelectedDate = Convert.ToDateTime(property.DefaultValue); |
| } |
| templateControl.Controls.Add(radDatePicker); |
| #endregion |
| break; |
| case "RadComboBox": |
| #region |
| RadComboBox radComboBox = new RadComboBox(); |
| radComboBox.ID = string.Format("RadComboBox_{0}", property.Id); |
| string[] options = property.Options.Split('#'); |
| string[] optionItemKeyValPair; |
| foreach (string optionItem in options) |
| { |
| optionItemoptionItemKeyValPair = optionItem.Split('$'); |
| radComboBox.Items.Add(new RadComboBoxItem(optionItemKeyValPair[0], optionItemKeyValPair[1])); |
| } |
| radComboBox.Items.Insert(0, new RadComboBoxItem(GetGlobalResourceObject("GeneralResource", "PleaseSelect").ToString(), "-1")); |
| if (!IsPostBack) radComboBox.FindItemByValue(property.DefaultValue).Selected = true; |
| templateControl.Controls.Add(radComboBox); |
| #endregion |
| break; |
| case "CheckBox": |
| #region |
| CheckBox checkBox = new CheckBox(); |
| checkBox.ID = string.Format("CheckBox_{0}", property.Id); |
| if (!IsPostBack) checkBox.Checked = property.DefaultValue == "0" ? false : true; |
| templateControl.Controls.Add(checkBox); |
| #endregion |
| break; |
| } |
| } |
and i call the method on grid's itemcreated event
| protected void SelectGrid_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem item = e.Item as GridDataItem; |
| Entities.Domain.Property property = item.DataItem as Entities.Domain.Property; |
| if (property != null && property.PropertyTypeCodelookup != null && !string.IsNullOrEmpty(property.PropertyTypeCodelookup.UiType)) |
| { |
| CreateCustomControl(item["PropertyValueColumn"], property); |
| } |
| } |
| } |
| public List<Property> SelectedProperties |
| { |
| get |
| { |
| List<Property> _selectedProperties=new List<Property>(); |
| Property tmpProperty; |
| if (_currentPropertyCollection != null && _currentPropertyCollection.Count > 0) |
| { |
| foreach (GridDataItem item in PropertySelectGrid.Items) |
| { |
| if (((CheckBox)item["Selection"].Controls[1]).Checked) |
| { |
| tmpProperty = _currentPropertyCollection.Find(p => p.Id == (Convert.ToInt64(item["Id"].Text))); |
| Control c = item["PropertyValueColumn"].Controls[0]; |
| string text = string.Empty; |
| if (c is RadTextBox || c is RadNumericTextBox) |
| { |
| if (c is RadTextBox) |
| { |
| text = ((RadTextBox)item["PropertyValueColumn"].Controls[0]).Text; |
| } |
| else if (c is RadNumericTextBox) |
| { |
| text = ((RadNumericTextBox)item["PropertyValueColumn"].Controls[0]).Text; |
| } |
| } |
| else if (c is RadDateInput) |
| { |
| if (((RadDateInput)item["PropertyValueColumn"].Controls[0]).SelectedDate.HasValue) |
| { |
| text = ((RadDateInput)item["PropertyValueColumn"].Controls[0]).SelectedDate.Value.ToString(); |
| } |
| } |
| else if (c is RadComboBox) |
| { |
| if (((RadComboBox)item["PropertyValueColumn"].Controls[0]).SelectedItem != null) |
| { |
| if (((RadComboBox)item["PropertyValueColumn"].Controls[0]).SelectedItem.Value != "-1") |
| { |
| text = ((RadComboBox)item["PropertyValueColumn"].Controls[0]).SelectedItem.Value; |
| } |
| } |
| } |
| else if (c is CheckBox) |
| { |
| if (((CheckBox)item["PropertyValueColumn"].Controls[0]).Checked) |
| { |
| text = "1"; |
| } |
| } |
| tmpProperty.DefaultValue = text; |
| _selectedProperties.Add(tmpProperty); |
| } |
| } |
| } |
| //string key = "UnitPropertySelectedList_" + WebSessionManager.DataFilter.CurrentId; |
| //if (!WebSessionManager.DataFilter.ObjectList.ContainsKey(key) || WebSessionManager.DataFilter.ObjectList[key] == null) |
| //{ |
| // List<Property> propertyList = new List<Property>(); |
| // WebSessionManager.DataFilter.Add(key, propertyList); |
| //} |
| //return (List<Property>)WebSessionManager.DataFilter.ObjectList[key]; |
| return _selectedProperties; |
| } |
function PrintRadGrid() {
var ClientsGrid = $find("<%=ClientsGrid.ClientID %>");
var f = ClientsGrid.get_masterTableView().get_filterExpressions().toString();
var previewWnd = window.open('print/Clients.aspx?Filter=' + escape(f), '', '', false);
previewWnd.print();
}
Problem is that the filter variable is always blank and I cannot get the SQL expression I need.
Any ideas?
Thanks!
| private void RecreateTabsPageViews() |
| { |
| if (Session["TabPageViewsContents"] == null) return; |
| List<Control> PageViewsList = (List<Control>)Session["TabPageViewsContents"]; |
| int index = 0; |
| foreach (Control c in PageViewsList) |
| { |
| CenterTabStribMultiPage.PageViews[index].Controls.Add(c); |
| index++; |
| } |
| } |
| <telerik:RadGrid ID="RadGrid1" DataSourceID="EntityDataSource1" AllowFilteringByColumn="false" | |
| runat="server" GridLines="None" AllowPaging="true" AllowSorting="false" OnPreRender="RadGrid1_PreRender" | |
| PageSize="6"> | |
| <PagerStyle Mode="NextPrevAndNumeric" /> | |
| <MasterTableView TableLayout="Auto" ShowHeader="false"> | |
| <ItemTemplate> | |
| <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %> | |
| <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>' runat="server"> | |
| <asp:Image ID="Image1" runat="server" ImageUrl=<%# Eval("Path")%> Height="40" Width="40" ImageAlign="Middle" /> | |
| </asp:Panel> | |
| </ItemTemplate> | |
| </MasterTableView> | |
| <GroupingSettings CaseSensitive="false" /> | |
| <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true" ReorderColumnsOnClient="true" AllowRowsDragDrop="true"> | |
| <Selecting AllowRowSelect="true" /> | |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" /> | |
| </ClientSettings> | |
| </telerik:RadGrid> |