Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
54 views
I took the code to have a treeview in a combobox and it works fine. Problem is, I need it to do an autopostback when somebody changes the value. I have put autopostback=true for the combobox (there isn't one for the treeview) and it works when you first come in and there's no value for the text in the combo box. But once it's been set, it doesn't do the autopostback.

Any thoughts?

TIA - Jeff.
Shinu
Top achievements
Rank 2
 answered on 31 Mar 2011
1 answer
127 views
I'm creating a grid dynamically based on filters the user provides. The issue(s) I'm having are:
  1. The column filters no longer work. That is, selecting "Contains" or "StartsWith" doesn't work.
  2. When going to page 2 of the grid, all records are returned (looks like the grid is rebinding and is bringing back every record in the db instead of filters the dataset that's already contained in the grid)

Here's my aspx:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/RADMasterPage.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Reporting_Report" Title="Untitled Page" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<%@ Register src="../Controls/ReportFilters.ascx" tagname="ReportFilters" tagprefix="RF" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
 
    <script type="text/javascript">
        function requestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="SectionHeader" ContentPlaceHolderID="cphSectionHeader" runat="server">
    <h3>Reporting</h3>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div>       
        <telerik:RadPanelBar ID="rpbFilters" Runat="server" Skin="Office2007"
            Width="100%" onitemclick="rpbFilters_ItemClick">
            <CollapseAnimation Type="Linear" Duration="200" />
            <ExpandAnimation Type="Linear" Duration="200" />
            <Items>
                <telerik:RadPanelItem Text="Report Filters" Expanded="true">
                    <Items>
                        <telerik:RadPanelItem Value="filters" runat="server">
                            <ItemTemplate>
                                <div>
                                    <RF:ReportFilters ID="rfFilters" runat="server" />
                                    <asp:Button ID="btnRunReport" runat="server" Text="Run Report" OnClick="RunReport" />
                                </div>
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>                   
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>       
    </div>
    <asp:Panel ID="pnlGrid" runat="server" Visible="false">   
    <div id="wrapper">
        <telerik:radajaxmanager id="ramReport" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rgReport">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgReport" LoadingPanelID="ralpReport" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:radajaxmanager>
        <telerik:radajaxloadingpanel
            enabled="true"
            id="ralpReport"           
            issticky="false"
            runat="server"
            skin=""
            transparency="50">
            <img id="imgLoader" src="../Images/loading3.gif" alt="Loading..." />
        </telerik:radajaxloadingpanel>
        <telerik:radajaxpanel
            clientevents-onrequeststart="requestStart"
            id="rapReport"
            loadingpanelid="ralpReport"
            runat="server">
             
            <telerik:RadGrid
                AllowFilteringByColumn="False"
                AllowPaging="True"
                AllowSorting="True"
                AutoGenerateColumns="False"
                DataSourceID="odsReports"
                EnableViewState="false"
                GridLines="None"
                ID="rgReport"
                OnExcelMLExportRowCreated="RadGrid1_ExcelMLExportRowCreated"
                OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated"
                runat="server"
                ShowFooter="True"
                ShowGroupPanel="True">
                 
                <ClientSettings
                    AllowColumnsReorder="true"
                    AllowDragToGroup="true"
                    ReorderColumnsOnClient="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" />
                </ClientSettings>
                 
                <ExportSettings
                    ExportOnlyData="true"
                    IgnorePaging="true"
                    OpenInNewWindow="true">
                    <Excel Format="ExcelML" />
                </ExportSettings>
                 
                <FilterMenu
                    EnableImageSprites="False" />
                 
                <GroupingSettings
                    CaseSensitive="false"
                    ShowUnGroupButton="true" />
                 
                <HeaderContextMenu
                    CssClass="GridContextMenu GridContextMenu_Default" />               
                 
                <PagerStyle
                    Mode="NextPrevNumericAndAdvanced" />
            </telerik:RadGrid>
        </telerik:radajaxpanel>
    </div>
    <asp:ObjectDataSource ID="odsReports" runat="server"
            SelectMethod="GetReportResults"
            TypeName="Budco.StoreFront.Reporting.BLL.ReportResultset" OnObjectCreating="ObjectCreating">
    </asp:ObjectDataSource>
    </asp:Panel>
</asp:Content>

And here is my code behind:

using System;
using System.Data;
using System.Web.UI;
using Telerik.Web.UI;
using Budco.StoreFront.Reporting;
using Budco.StoreFront.Reporting.BLL;
using Budco.StoreFront.Common;
using Telerik.Web.UI.GridExcelBuilder;
using System.Web.UI.WebControls;
 
 
 
public partial class Reporting_Report : System.Web.UI.Page
{
    bool isConfigured = false;
    int filterDelay;
    int? _ReportID = null;
    string _ReportName = null;
    ReportResultset _ReportResultset = null;
    int? _ReportResultsID = null;
     
 
    protected void Page_Load(object sender, EventArgs e)
    {
        object oReportID = Request["ReportID"];
        object oReportName = Request["ReportName"];
        object oReportResultsID = Request["ReportResultsID"];
 
        if (oReportID != null)
        {
            _ReportID = Convert.ToInt32(oReportID);
            _ReportResultset = new ReportResultset((int)_ReportID);
        }
        if (_ReportID == null && oReportName != null)
        {
            _ReportName = oReportName.ToString();
            _ReportResultset = new ReportResultset(_ReportName);
        }
 
        if (oReportResultsID != null)
        {
            _ReportResultsID = Convert.ToInt32(oReportResultsID);
        }
 
 
        //if (!Page.IsPostBack)
        //{
            if (_ReportID != null || _ReportName != null)
            {
                GetParameterAttributes paramAttributes = new GetParameterAttributes();
                Reporting.GetParameterAttributesDataTable paramAttributesDT = paramAttributes.GetData(_ReportID);
                ASP.controls_reportfilters_ascx ctrl = (ASP.controls_reportfilters_ascx)rpbFilters.FindItemByValue("filters").FindControl("rfFilters");
                ctrl.BindControls(paramAttributesDT);
            }
        //}
        if (_ReportID != null || _ReportName != null)
        {
            //this.btnRunReport.Enabled = false;
        }
    }
 
 
    protected void RadGrid1_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
    {
        if (e.RowType == GridExportExcelMLRowType.DataRow)
        {
            //CellElement cell = e.Row.Cells.GetCellByName("Price");
            //cell.StyleValue = cell.StyleValue == "itemStyle" ? "priceItemStyle" : "alternatingPriceItemStyle";
        }
 
        if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.HeaderRow)
        {
            e.Worksheet.WorksheetOptions.PageSetup.PageHeaderElement.Data = "This is the header";
            e.Worksheet.WorksheetOptions.PageSetup.PageHeaderElement.Margin = 0.25;
            e.Worksheet.WorksheetOptions.PageSetup.PageFooterElement.Data = "This is the footer";
            e.Worksheet.WorksheetOptions.PageSetup.PageFooterElement.Margin = 0.25;
        }
 
        if (!isConfigured)
        {
            e.Worksheet.Name = "Test Agent Report";
 
            PageSetupElement pageSetup = e.Worksheet.WorksheetOptions.PageSetup;
            pageSetup.PageLayoutElement.IsCenteredVertical = true;
            pageSetup.PageLayoutElement.IsCenteredHorizontal = true;
            pageSetup.PageMarginsElement.Left = 0.75;
            pageSetup.PageMarginsElement.Top = 0.5;
            pageSetup.PageMarginsElement.Right = 0.5;
            pageSetup.PageMarginsElement.Bottom = 0.75;
            pageSetup.PageLayoutElement.PageOrientation = PageOrientationType.Landscape;
 
            e.Worksheet.WorksheetOptions.AllowFreezePanes = true;
            e.Worksheet.WorksheetOptions.LeftColumnRightPaneNumber = 1;
            e.Worksheet.WorksheetOptions.TopRowBottomPaneNumber = 1;
            e.Worksheet.WorksheetOptions.SplitHorizontalOffset = 1;
            e.Worksheet.WorksheetOptions.SplitVerticalOffest = 1;
 
            e.Worksheet.WorksheetOptions.ActivePane = 2;
            isConfigured = true;
        }
    }
 
 
    protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
    {
        StyleElement priceStyle = new StyleElement("priceItemStyle");
        priceStyle.NumberFormat.FormatType = NumberFormatType.Currency;
        priceStyle.FontStyle.Color = System.Drawing.Color.Red;
        e.Styles.Add(priceStyle);
 
        StyleElement alternatingPriceStyle = new StyleElement("alternatingPriceItemStyle");
        alternatingPriceStyle.NumberFormat.FormatType = NumberFormatType.Currency;
        alternatingPriceStyle.FontStyle.Color = System.Drawing.Color.Red;
        e.Styles.Add(alternatingPriceStyle);
 
        foreach (StyleElement style in e.Styles)
        {
            switch (style.Id)
            {
                case "itemStyle": style.FontStyle.Color = System.Drawing.Color.Green; break;
            }
        }
    }
 
    protected void RunReport(object sender, EventArgs e)
    {
        if (_ReportID != null || _ReportName != null)
        {
            ASP.controls_reportfilters_ascx ctrl = (ASP.controls_reportfilters_ascx)rpbFilters.FindItemByValue("filters").FindControl("rfFilters");
            Panel pnl = (Panel)ctrl.FindControl("pnlFilters");
            if (pnl.HasControls())
            {
                //GetParameterAttributes paramAttributes = new GetParameterAttributes();
                //Reporting.GetParameterAttributesDataTable paramAttributesDT = paramAttributes.GetData(_ReportID);
                _ReportResultset.ParameterValues.Clear();
                 
                foreach (Control control in pnl.Controls)
                {
                    string theControl = control.GetType().ToString();
                    switch (control.GetType().ToString())
                    {
                        case "System.Web.UI.WebControls.TextBox":
                            _ReportResultset.ParameterValues.Add(new Budco.StoreFront.Common.Parameter(control.ID.Substring(3), ((TextBox)control).Text));
                            break;
                    }
                }
            }
 
            // Get ReportResults & ReportResultsColumn data
            ReportResults rptResults = new ReportResults();
            //ReportResultsColumn rptResultsColumn = new ReportResultsColumn();
            GetReportResultsColumns rptResultsColumn = new GetReportResultsColumns();
            Reporting.ReportResultsDataTable resultsDT = rptResults.GetData(this._ReportResultsID, _ReportID);
            Reporting.GetReportResultsColumnsDataTable resultsColumnDT = rptResultsColumn.GetData(null, resultsDT.Rows[0]["ResultsName"].ToString());
 
            // Set RadGrid level properties
            rgReport.Skin = "Office2007"; //resultsDT.Rows[0]["Skin"].ToString();
            rgReport.HeaderStyle.CssClass = resultsDT.Rows[0]["HeaderStyleCssClass"].ToString();
            rgReport.ItemStyle.CssClass = resultsDT.Rows[0]["ItemStyleCssClass"].ToString();
            rgReport.FooterStyle.CssClass = resultsDT.Rows[0]["FooterStyleCssClass"].ToString();
 
            // Set MasterTableView level properties
            rgReport.MasterTableView.CommandItemSettings.ShowExportToCsvButton = (bool)resultsDT.Rows[0]["ShowExportToCsvButton"];
            rgReport.MasterTableView.CommandItemSettings.ShowExportToExcelButton = (bool)resultsDT.Rows[0]["ShowExportToExcelButton"];
            rgReport.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
            rgReport.MasterTableView.AllowFilteringByColumn = true;
            rgReport.MasterTableView.AutoGenerateColumns = false;
            rgReport.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
            rgReport.MasterTableView.ShowFooter = true;
            rgReport.MasterTableView.TableLayout = GridTableLayout.Auto;
            this.rgReport.MasterTableView.Columns.Clear(); // this prevents duplicate columns which causes an error
 
            foreach (DataRow row in resultsColumnDT.Rows)
            {
                switch (row["ColumnTypeName"].ToString())
                {
                    case "Telerik.Web.UI.GridBoundColumn":
                        GridBoundColumn boundColumn = new GridBoundColumn();
                        this.rgReport.MasterTableView.Columns.Add(boundColumn);
 
                        boundColumn.AllowFiltering = (bool)row["AllowFiltering"];
                        boundColumn.AllowSorting = (bool)row["AllowSorting"];
                        boundColumn.AutoPostBackOnFilter = (bool)row["AutoPostBackOnFilter"];
                        boundColumn.DataField = row["DataField"].ToString();
                        boundColumn.DataFormatString = row["DataFormatString"].ToString();
                        boundColumn.FilterControlAltText = row["FilterControlAltText"].ToString();
                        bool result = Int32.TryParse(row["FilterDelay"].ToString(), out filterDelay);
                        boundColumn.FilterDelay = filterDelay;
                        boundColumn.HeaderText = row["HeaderText"].ToString();
                        boundColumn.SortExpression = row["DataField"].ToString();
                        boundColumn.UniqueName = row["DataField"].ToString();
                        break;
 
                    case "Telerik.Web.UI.GridDateTimeColumn":
                        GridDateTimeColumn dateTimeColumn = new GridDateTimeColumn();
                        this.rgReport.MasterTableView.Columns.Add(dateTimeColumn);
 
                        dateTimeColumn.AllowFiltering = (bool)row["AllowFiltering"];
                        dateTimeColumn.AllowSorting = (bool)row["AllowSorting"];
                        dateTimeColumn.AutoPostBackOnFilter = (bool)row["AutoPostBackOnFilter"];
                        dateTimeColumn.DataField = row["DataField"].ToString();
                        dateTimeColumn.DataFormatString = row["DataFormatString"].ToString();
                        dateTimeColumn.DataType = System.Type.GetType(row["DataType"].ToString());
                        dateTimeColumn.FilterControlAltText = row["FilterControlAltText"].ToString();
                        bool result2 = Int32.TryParse(row["FilterDelay"].ToString(), out filterDelay);
                        dateTimeColumn.FilterDelay = filterDelay;
                        dateTimeColumn.HeaderText = row["HeaderText"].ToString();
                        dateTimeColumn.PickerType = GridDateTimeColumnPickerType.DatePicker;
                        dateTimeColumn.SortExpression = row["DataField"].ToString();
                        dateTimeColumn.UniqueName = row["DataField"].ToString();
                        break;
 
                    case "Telerik.Web.UI.GridNumericColumn":
                        GridNumericColumn numericColumn = new GridNumericColumn();
                        this.rgReport.MasterTableView.Columns.Add(numericColumn);
 
                        foreach (GridAggregateFunction gaf in Enum.GetValues(typeof(GridAggregateFunction)))
                        {
                            if (gaf.ToString().Equals(row["Aggregate"].ToString()))
                            {
                                numericColumn.Aggregate = gaf;
                                break;
                            }
                        }
                        numericColumn.AllowFiltering = (bool)row["AllowFiltering"];
                        numericColumn.AllowSorting = (bool)row["AllowSorting"];
                        numericColumn.AutoPostBackOnFilter = (bool)row["AutoPostBackOnFilter"];
                        numericColumn.DataField = row["DataField"].ToString();
                        numericColumn.DataFormatString = row["DataFormatString"].ToString();
                        numericColumn.DataType = System.Type.GetType(row["DataType"].ToString());
                        numericColumn.FilterControlAltText = row["FilterControlAltText"].ToString();
                        bool result3 = Int32.TryParse(row["FilterDelay"].ToString(), out filterDelay);
                        numericColumn.FilterDelay = filterDelay;
                        numericColumn.FooterAggregateFormatString = row["FooterAggregateFormatString"].ToString();
                        numericColumn.HeaderText = row["HeaderText"].ToString();
                        numericColumn.SortExpression = row["DataField"].ToString();
                        numericColumn.UniqueName = row["DataField"].ToString();
                        break;
 
                    default:
                        break;
                }
 
            }
 
            rgReport.Rebind(); // this causes the grid to bring back every record from the db.
            pnlGrid.Visible = true;
        }
    }
    protected void rpbFilters_ItemClick(object sender, RadPanelBarEventArgs e)
    {
         
    }
 
 
    protected void ObjectCreating(object sender, ObjectDataSourceEventArgs e)
    {
        if (_ReportID != null || _ReportName != null)
        {
            //_ReportResultset = new ReportResultset((int)_ReportID);
            e.ObjectInstance = _ReportResultset;
        }
    }
}


What am I doing wrong here?

Thanks,
Mark
Mira
Telerik team
 answered on 31 Mar 2011
1 answer
147 views
I have a radgrid which I am binding in the server side using the needdatasource event. After the initial bind, I need to refresh the grid once every 10 seconds. I need to refresh the grid only if the data has changed since the previous bind.

I have these lines of code in my javascript.

window.setInterval("fetchrealtime()", 10000);
 
     function fetchrealtime() {
            StopTimer();
            var masterTable = $find("<%= InquiryGrid.ClientID %>").get_masterTableView();
            masterTable.fireCommand("RebindGrid");
        }


This fires up the need datasource event of the grid. Is there a way I can bind the grid conditionally in the needdatasource event ?
If the data hasn't changed then I want to skip the refreshing of the grid and retain the previously bound content. Following conditional binding of the grid throws error in some of the GridTemplateBound columns.

protected void InquiryGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
     {
         InquirySearchOutput results = inquirySvc.GetInquiryResults();
         List<InquiryGridView> gridResults = results.gridResults;
 if(results.hasDelta == true)
 {
         InquiryGrid.VirtualItemCount = results.recordCount;
         InquiryGrid.DataSource = gridResults;
 }
     }


I know that I can check if the data has changed by making a wcf call from client side. I really wanted to avoid making multiple calls to get the data/ check for data.
Martin
Telerik team
 answered on 31 Mar 2011
3 answers
108 views
Ajax 2010.3.1317.35

I have a radgrid with some hyperlink columns, and a contextmenu atteched. is there any way to keep the browser menu when right clicking on hyperlinks, keeping the contextmenu on "other" row right click renderings?

here´s my grid code if its to any help.

<telerik:RadGrid ID="grCaseList" runat="server" Skin="Windows7" 
    AllowPaging="True" AllowSorting="True" GridLines="None" ShowGroupPanel="True" 
        Width="100%" AutoGenerateColumns="False" 
        onitemdatabound="grCaseList_ItemDataBound">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Windows7"></HeaderContextMenu>
  
    <MasterTableView EnableColumnsViewState="true" GroupsDefaultExpanded="false" GroupLoadMode="Client" >
      
        <CommandItemSettings ExportToPdfText="Export to Pdf" >
        </CommandItemSettings>
        <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridHyperLinkColumn DataTextField="cs_id" DataType="System.Int32" 
                FilterControlAltText="Filter cs_id column" HeaderText="ID" 
                UniqueName="cs_id" DataNavigateUrlFields="caseUrl" Groupable="False">
            </telerik:GridHyperLinkColumn>
            <telerik:GridHyperLinkColumn DataTextField="cs_header" 
                FilterControlAltText="Filter cs_header column" HeaderText="Rubrik" 
                UniqueName="cs_header" DataNavigateUrlFields="caseUrl" Groupable="False">
            </telerik:GridHyperLinkColumn>
            <telerik:GridHyperLinkColumn DataTextField="nt_us_name" 
                FilterControlAltText="Filter nt_us_name column" HeaderText="Senast ändrad av" 
                UniqueName="nt_us_name">
            </telerik:GridHyperLinkColumn>
            <telerik:GridDateTimeColumn DataField="cs_timePosted" 
                FilterControlAltText="Filter cs_timePosted column" HeaderText="Inlagt" 
                UniqueName="cs_timePosted" DataFormatString="{0:yy-MM-dd hh:mm}">
            </telerik:GridDateTimeColumn>
            <telerik:GridDateTimeColumn DataField="cs_timePlanned" 
                DataType="System.DateTime" FilterControlAltText="Filter cs_timePlanned column" 
                HeaderText="Planerat" UniqueName="cs_timePlanned" DataFormatString="{0:yy-MM-dd}">
            </telerik:GridDateTimeColumn>
            <telerik:GridDateTimeColumn DataField="cs_timeClosed" 
                FilterControlAltText="Filter cs_timeClosed column" HeaderText="Avslutat" 
                UniqueName="cs_timeClosed" DataFormatString="{0:yy-MM-dd hh:mm}">
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="cs_fromIP" 
                FilterControlAltText="Filter cs_fromIP column" HeaderText="IP" 
                UniqueName="cs_fromIP">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="cs_fritext" 
                FilterControlAltText="Filter cs_fritext column" HeaderText="Fritext" 
                UniqueName="cs_fritext">
            </telerik:GridBoundColumn>
            <telerik:GridHyperLinkColumn DataTextField="cs_fromComputerName" 
                FilterControlAltText="Filter cs_fromComputerName column" HeaderText="Dator" 
                UniqueName="cs_fromComputerName">
            </telerik:GridHyperLinkColumn>
            <telerik:GridBoundColumn DataField="st_name" 
                FilterControlAltText="Filter st_name column" HeaderText="Status" 
                UniqueName="st_name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ty_name" 
                FilterControlAltText="Filter ty_name column" HeaderText="Typ" 
                UniqueName="ty_name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="prio" 
                FilterControlAltText="Filter prio column" HeaderText="Prio" UniqueName="prio">
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn DataField="nt_timePosted" 
                FilterControlAltText="Filter nt_timePosted column" HeaderText="Uppdaterad" 
                UniqueName="nt_timePosted" DataFormatString="{0:yy-MM-dd hh:mm}">
            </telerik:GridDateTimeColumn>
            <telerik:GridHyperLinkColumn DataTextField="cs_us_name" 
                FilterControlAltText="Filter cs_us_name column" HeaderText="Inlagt av" 
                UniqueName="cs_us_name">
            </telerik:GridHyperLinkColumn>
            <telerik:GridHyperLinkColumn DataTextField="adm_ad_username" 
                FilterControlAltText="Filter adm_ad_username column" HeaderText="Ansvarig" 
                UniqueName="adm_ad_username">
            </telerik:GridHyperLinkColumn>
            <telerik:GridBoundColumn DataField="maxRead" 
                FilterControlAltText="Filter maxRead column" HeaderText="maxRead" 
                UniqueName="maxRead" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="maxNote" 
                FilterControlAltText="Filter maxNote column" HeaderText="maxNote" 
                UniqueName="maxNote" Visible="False">
            </telerik:GridBoundColumn>
        </Columns>
  
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
  
    </MasterTableView>
    <ClientSettings AllowDragToGroup="True">
        <Resizing AllowColumnResize="True"></Resizing>
        <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
    <Selecting AllowRowSelect="true" />
  
    </ClientSettings>
  
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
  
    <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
  
    <telerik:RadContextMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick"
        EnableRoundedCorners="true" EnableShadows="true" Skin="Windows7">
        <Items>
            <telerik:RadMenuItem Text="Öppna ärende" />
            <telerik:RadMenuItem Text="Avsluta ärende" />
            <telerik:RadMenuItem Text="Ta bort ärende" />
        </Items>
    </telerik:RadContextMenu>
Tsvetina
Telerik team
 answered on 31 Mar 2011
2 answers
179 views
I have a radgrid which is using GridTemplateColumn to enable me to manage the content the way I want.  The Grid worked when i was using GridBoundColumns but when i switch i'm getting the following error.

"exhibition with ID 4 cannot be updated. Reason: Cannot insert the value NULL into column 'exhibitionTitle', table 'trevorbollenart.dbo.exhibitions'; column does not allow nulls. UPDATE fails. The statement has been terminated."

All the controls have been filled in (including exhibitionTitle) does anyone have any ideas? I'm guessing I can mix and match GridTemplateColumn and GridBoundColumns?


Code show below.

<h2>Manage exhibitions</h2>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
          
        <p>Items marked with a <span class="radgrid-required">*</span> are required. </p>
        <br />
          
        <br />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Black" runat="server" />
       <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" PageSize="10"
            AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowSorting="True" Skin="Black" ShowStatusBar="True" >
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView DataKeyNames="exhibitionID" DataSourceID="SqlDataSource1" CommandItemDisplay="Bottom" Name="exhibitions"
        CommandItemSettings-AddNewRecordText="Add New Exhibition"  >
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
<CommandItemSettings AddNewRecordText="Add New Exhibition"></CommandItemSettings>
    <Columns>
       <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderText="Edit">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
          
        <telerik:GridTemplateColumn HeaderText="Exhibition Title" UniqueName="exhibitionTitle" >
            <EditItemTemplate>
                <asp:TextBox ID="txtExhibitionTitle" runat="server" Width="300" MaxLength="500" Text='<%#Eval("exhibitionTitle")%>' /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ErrorMessage="Please enter the exhibition title" ControlToValidate="txtExhibitionTitle" Display="Dynamic" />
            </EditItemTemplate>
            <ItemTemplate>
            <%#Eval("exhibitionTitle")%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Gallery Name">
            <EditItemTemplate>
                <asp:TextBox ID="galleryName" runat="server" Width="300" MaxLength="100" Text='<%#Eval("galleryName")%>'  /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvGalleryName" runat="server" ErrorMessage="Please enter the gallery name" ControlToValidate="galleryName" Display="Dynamic" />
            </EditItemTemplate>
            <ItemTemplate>
            <%#Eval("galleryName")%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
         
         <Telerik:GridDateTimeColumn DataField="eventDateTime"
            HeaderText="Event Date & Time" SortExpression="eventDateTime"
            UniqueName="eventDateTime" PickerType="DateTimePicker"  >
        </Telerik:GridDateTimeColumn>
        <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Gallery Address">
            <ItemTemplate>
            <%#Eval("galleryAddress")%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="galleryAddress" runat="server" TextMode="MultiLine" Height="100" Width="300" MaxLength="500" Text='<%#Eval("galleryAddress")%>'  /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvGalleryAddress" runat="server" ErrorMessage="Please enter the gallery address" ControlToValidate="galleryAddress" Display="Dynamic" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Gallery Website">
            <ItemTemplate>
            <%#Eval("galleryUrl")%>
            </ItemTemplate>
            <EditItemTemplate>
                http://<;;asp:TextBox ID="galleryUrl" runat="server" Width="300" MaxLength="100" /> i.e. www.trevorbollen.co.uk
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn DataField="galleryTel" HeaderText="Gallery Tel No"
            SortExpression="galleryTel" UniqueName="galleryTel">
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn HeaderText="Notes">
            <ItemTemplate>
            <%#Eval("notes")%>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox ID="notes" runat="server" TextMode="MultiLine" Width="300" MaxLength="500" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
       <telerik:GridButtonColumn ConfirmText="Delete this exhibition?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
          
    </Columns>
  
<EditFormSettings>
  
<EditColumn  ButtonType="ImageButton" CancelImageUrl="~/images/btn-cancel.jpg" UpdateImageUrl="~/images/btn-update.jpg" InsertImageUrl="~/images/btn-insert.jpg"  />
</EditFormSettings>
  
</MasterTableView>
            <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" ForeColor="White" Wrap="True" />
        </telerik:RadGrid>
        <br />
        
      
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:trevorbollenartConn %>"
            InsertCommand="AddNewExhibition" InsertCommandType="StoredProcedure"
            SelectCommand="GetAllExhibitions" SelectCommandType="StoredProcedure"
            UpdateCommand="UpdateExhibition" UpdateCommandType="StoredProcedure"
            DeleteCommand="DeleteExhibition" DeleteCommandType="StoredProcedure">
            <DeleteParameters>
                <asp:Parameter Name="exhibitionID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="exhibitionID" Type="Int32" />
                <asp:Parameter Name="exhibitionTitle" Type="String" />
                <asp:Parameter Name="galleryName" Type="String" />
                <asp:Parameter Name="eventDateTime" Type="DateTime" />
                <asp:Parameter Name="galleryAddress" Type="String" />
                <asp:Parameter Name="galleryURL" Type="String" />
                <asp:Parameter Name="galleryTel" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="exhibitionTitle" Type="String" />
                <asp:Parameter Name="galleryName" Type="String" />
                <asp:Parameter Name="eventDateTime" Type="DateTime" />
                <asp:Parameter Name="galleryAddress" Type="String" />
                <asp:Parameter Name="galleryURL" Type="String" />
                <asp:Parameter Name="galleryTel" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
      
    </div>
  
</asp:Content>
stevied
Top achievements
Rank 2
 answered on 31 Mar 2011
1 answer
122 views

This is Carlos Mendoza from Accenture, US.

I’m not sure if this is also the same email address for requesting technical assistance so I’d appreciate it if you just forward to the correct group if so.

Our project purchased Telerik’s HTML editor product, and implemented it on our corporate web site, www.accenture.com

That web site is built on MOSS 2007. We have another web site, microsite.accenture.com, built in MOSS 2007 too, in which Telerik’s HTML editor is implemented in there too.

On the Microsite web site, Telerik’s toolbar is able to retrieve the site’s alternate CSS file (.css), and display the CSS classes defined inside the CSS file on the Style dropdown of Telerik’s toolbar, so they can be used by our end users. See attached screenshot below.

 

 

 

 

 

 

 

 

On the www.accenture.com web site, this is not happening on Telerik’s Style dropdown section.

Our clients would like the same behavior of the Style dropdown as the Microsites web site. Is there any configuration or line of code we should implement on the www.accenture.com platform so additional CSS classes defined on the site’s alternate CSS would appear on the Style dropdown of Telerik’s HTML editor toolbar?

 

Please advise.

 

I’d be glad to hop into a call if needed. Just tell me the telephone number of your technical support team.

 

Looking forward to hearing from you!

Stanimir
Telerik team
 answered on 31 Mar 2011
9 answers
87 views
Hello,

I am using the Popup Edit Forms with my RadGrid.  When I set the MasterTableView.EditFormSettings.CaptionFormatString to some string, the Popup window appears with two titles that say the same thing: the title of the window, and a form title below the window's title.  Both captions say the same thing...

I would like to remove the form title but leave the Popup window title... Is that possible??

Thanx,
Manuel
Pavel
Telerik team
 answered on 31 Mar 2011
1 answer
631 views
Hello,

I've implemented a requiredfieldvalidator for a radcombobox which works fine on submitting the form, however I would like to show the red asterisk before the page is submitted to indicate to the user that the field is required.  Using

Page.Validate();

in the Page_load event on the server activates the required field validators that are defined against text boxes, but I can't get the validator associated  with the combobox to show.

 
      <table>
        <tr>
            <td><telerik:RadComboBox id="ddlCostCategory" DataTextField="Name" DataValueField="ID" runat="server" SkinID="WideDll"  ></telerik:RadComboBox></td>
            <td><asp:RequiredFieldValidator runat="server" ControlToValidate ="ddlCostCategory" ID="reqValCostCategory" Text="*" ErrorMessage="Cost Category is required" InitialValue="[Select...]" ></asp:RequiredFieldValidator></td>
        </tr>
      </table>

The combobox si bound to a list with the first item having the text of [Select...] before the Page.Validate is called:

var query2 = from c in PNGC_SmartGridContext.CostCategories select c;
               IList<CostCategory> _costCategories = query2.ToList<CostCategory>();
               _costCategories.Insert(0, new CostCategory() { ID = 0, Name = "[Select...]" });
               ddlCostCategory.DataSource = _costCategories;
               ddlCostCategory.DataBind();

Note that the actual validation on submit works fine, it's just the ability to pre-trigger the red asterisk that would be great.

Thanks

Jonathan
Peter
Telerik team
 answered on 31 Mar 2011
1 answer
65 views
When I click "Add a new record", the Loading... icon at the bottom of the grid spins continuously, but the Edit works fine.

Actually, I found the problem, but I'm not sure how to fix it.

The EditFormType is Template. In the template I have the following:
<td>
    <asp:RadioButtonList ID="CommentLevel_RadioButtonList" runat="server"
                 DataSourceID="CommentLevel_SqlDataSource" DataTextField="CodeValue"
                 DataValueField="CodeName" RepeatDirection="Horizontal"
        
SelectedValue='<%# Eval("CommentCategory") %>'>
    </asp:RadioButtonList>
</td>

The problem is with the SelectedValue. When editing an existing record, there is a value in CommentCategory; but when inserting it is null.

What is the best way for me to conditionally include the SelectedValue property? On a new record, I want don't want a default value -- the user needs to think about which it should be. (An error message displays before saving if null.)
Jayesh Goyani
Top achievements
Rank 2
 answered on 31 Mar 2011
3 answers
119 views
I've got a TreeView in a combo box that works fine. What I'd like to do is keep track of which nodes are expanded in the treeview between pages (I use the control on multiple pages) I've seen code to do a treeview in a combobox and saving a treeview to a session variable but can't seem to get the combination of the two to work correctlty.

Anybody have any suggestions?

TIA - Jeff.
Shinu
Top achievements
Rank 2
 answered on 31 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?