Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
143 views

Requirements

RadControls version

2009.Q2

.NET version

3.5

Visual Studio version

2008

programming language

C#

browser support

all browsers supported by RadControls


PROJECT DESCRIPTION
@Telerik: I used the dll from RadControls_for_ASP.NET_AJAX_2009_2_701_trial_hotfix.zip - but I get no trial messages. Could you please check if the DLL is really the trial version.

Assume a (common) scenario where a column of a GridRow references a different table - the "master table" holds an ID and the related table this ID and some "Name" for it.
A typical use for a GridDropDownColumn.

But sometimes I came to a point where I couldn't use a GridDropDownColum - this happened when I had to do "very special customizations".
At this time I had to use a GridTemplateColumn. For the EditItemTemplate this is no problem - simply use a RadComboBox.
But how about the ItemTemplate?
One solution is to use a RadComboBox again - but the User should not be able to change a selection (this could confuse him).
To set the RadComboBox to Enabled="false" is also not really a solution - the thing is almost impossible to read.
Another approach is to define a datasource which allows to select the "Name" by giving an ID or to get the master data from some kind of join - which could make problems if you want to update the data.
Often I use "cached data" for things like "Country, Status, Region, Role...) - so the data is there - and I can access it very fast.
And last not least - I want to do it "the easy way" - no code behind for every grid which holds such a column.

The idea - I want to have a kind of Label which acts exactly like a ComboBox - I have a datasource(id), a selected value and so on.
As a result I get the same as with a ComboBox - but not a "unreadable" disabled thing - I just get a label (some kind of static text).
In simple words - I get the same result as with a GridDropDownColumn - but with full customization capabilities.

I built such a control (rough done -- Css class and other attributes are not rendered) and here it is.
The use is almost identical to a RadComboBox - here an example for a templated column using this control.
<telerik:GridTemplateColumn DataField="FunctionID" DataType="System.Int32" HeaderText="Function" SortExpression="FunctionID" UniqueName="FunctionID">  
    <ItemTemplate> 
        <cc1:ComboLabel runat="server" DataTextField="FunctionName" DataValueField="FunctionID" DataSourceID="odsTestFunctions" SelectedValue='<%# Eval("FunctionID") %>' /> 
        &nbsp;&nbsp;(<%# (string)((int)Eval("FunctionID")<2 ? "<b style='color:red;'>Handle with care</b>" : "Teasing enabled") %>)  
    </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadComboBox ID="cbFunctionID" runat="server" DataTextField="FunctionName" DataValueField="FunctionID" DataSourceID="odsTestFunctions" SelectedValue='<%# Bind("FunctionID") %>' /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 
 
You can see - both controls are almost identical - I set exactly the same values for
DataTextField, DataValueField, DataSourceID and SelectedValue

I use this control very often - and hope it is useful for you also.
To enhance the thing (more render capabilities) just change the function Render in ComboLabel (last function at the end).

Kind Regards

Manfred
Yavor
Telerik team
 answered on 08 Jul 2009
2 answers
112 views
I'm looking to make some small changes to a couple of the embeded skins. Is it possible to override specific styles, or do I have to use a custom skin if I want to make any changes?
Paul
Telerik team
 answered on 08 Jul 2009
0 answers
71 views
Hi
     I am using Radgrid having filtering controls. I used to call each filter control event at code behind. But theproblem is i could get filtered data only from the last control event fired,though i preserved the first control value it didnt take an account that value by the last control event value only taken.

So i need the filtering based on all control values even though i used to select randomly

My cs code:

//First Combo
protected void JurisdictionCodeComboBox_IndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string filterExpression = "";
        string query = "";

        if (e.Text.IndexOf(",") > -1)
        {
            string[] values = e.Text.Split(',');

            for (int i = 0; i < values.Length; i++)
            {
                query += "'" + values[i] + "',";
            }

            query = query.Remove(query.Length-1, 1);
        }
        else
        {
            query = "'" + e.Text + "'";
        }
        if (e.Value != "All")
        {
            filterExpression = "([JurisdictionCode] in (" + query + "))";
        }
        else
        {
            filterExpression = "([JurisdictionCode] <> '')";
        }
        hdnJurisdictionCode.Value = e.Text.ToString();
        RadGrid1.MasterTableView.FilterExpression = filterExpression;
       

    }

    //Second Combo
    protected void FergTechNumComboBox_IndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string filterExpression = "";
        string query = "";

        if (e.Text.IndexOf(",") > -1)
        {
            string[] values = e.Text.Split(',');

            for (int i = 0; i < values.Length; i++)
            {
                query += "'" + values[i] + "',";
            }

            query = query.Remove(query.Length - 1, 1);
        }
        else
        {
            query = "'" + e.Text + "'";
        }
        

        if (e.Value != "All")
        {
            filterExpression = "([FergTechNum] in (" + query + "))";
        }
        else
        {
            filterExpression = "([FergTechNum] <> '')";
        }
        hdnFergTechNum.Value = e.Text.ToString();
        RadGrid1.MasterTableView.FilterExpression = filterExpression;
      
    }
   

Appu

Appu
Top achievements
Rank 1
 asked on 08 Jul 2009
2 answers
292 views
I'm just starting to demo the RadGrid and decided to copy the example from:-
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/slider/defaultcs.aspx

I pasted in the sample code from the DefaultCS.aspx and DefaultVB.aspx.vb sections.  I did some slight modifications so I was calling data from our own database and ran the project.  I noticed in SQL Server profiler that my query was being called twice everytime I used the page slider.  After looking at the sample code that I pasted in I noticed that if I remove:-

OnNeedDataSource="RadGrid1_NeedDataSource"

... from the HTML (DefaultCS.aspx) if only fires once.  Everything still seems to work fine still.  Is this a mistake in your sample and is it not required or have I maybe done something wrong when I cut and pasted the sample code into our application?  I am just checking that removing this from the HTML will not have any implications.

Thanks
Chris
Top achievements
Rank 2
 answered on 08 Jul 2009
2 answers
69 views
Following on from this thread :
http://www.telerik.com/community/forums/aspnet-ajax/calendar/input-elemens-causing-section-508-failure.aspx

I can't get this example to work - my site continually complains that it is:
Unable to find control with id 'dnn_ctr604_EditCMIS_Meetings_txtcalMeetingDate_DateInput1_text that is associated with the Label 'Label2'.

Is there an implementation of this technique to label all parts of the calendar that is more up to date?
Holly
Top achievements
Rank 1
 answered on 08 Jul 2009
1 answer
117 views
Hi,
Anyone help me to add menu splitter(divider, i.e a line between two menu items) in RadMenu. Is there any built in style to add this. This is urgent. Please help anyone

Thanks and Regards
Natraj
Paul
Telerik team
 answered on 08 Jul 2009
1 answer
189 views
We've got some Grids wired up to stored procedures, with it handling all CRUD operations.

What I'd like to do is set an intial filter in the Grid PreRender - but the only example I've seen utilizes a standard text query via the where clause.

Is this possible?
Georgi Krustev
Telerik team
 answered on 08 Jul 2009
1 answer
135 views
We have an application load balancing across three web servers. We have received reports that additions made to the custom dictionary is not always remembered.

My feeling is this may be due to the web cluster with each server in the farm holding it's own copy of the dictionaries. Is this likely?

If this premis is correct are there any recommended configuration settings to cater for installation on a web farm? 
Lini
Telerik team
 answered on 08 Jul 2009
1 answer
302 views
I have a grid control which I have enabled client-side binding using a web service as the datasource. 

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
    <script type="text/javascript">  
        function RadGrid1_DataBinding(sender, args) {  
            // This event will be raised twice by default!   
            // The first call will retrieve data and the second call will retrieve total items count.  
            // If you want to cancel the event you can use:  
            // args.set_cancel(true);  
 
            // get data source location, method name and arguments  
            var dataSourceLocation = args.get_location();  
            var selectMethodName = args.get_methodName();  
            var methodArguments = args.get_methodArguments();  
 
            // set data source location and method name  
            // args.set_location("url to your data source");  
            // args.set_methodName("your method name");  
 
            // The grid will always pass by default four arguments for the SelectMethod.  
            // SelectCountMethod will be called with no arguments by default!  
 
            // get names for select parameters  
            var startRowIndexParameterName = sender.ClientSettings.DataBinding.StartRowIndexParameterName;  
            // default is "startRowIndex".   
 
            var maximumRowsParameterName = sender.ClientSettings.DataBinding.MaximumRowsParameterName;  
            // default is "maximumRows"  
 
            var sortParameterName = sender.ClientSettings.DataBinding.SortParameterName;  
            // default is "sortExpression"  
 
            var filterParameterName = sender.ClientSettings.DataBinding.FilterParameterName;  
            // default is "filterExpression"  
 
            // construct your own arguments  
            // var myMethodArguments = new Object();  
            // myMethodArguments.myArgumentName = "myArgumentValue";  
            // args.set_methodArguments(myMethodArguments);  
        }  
 
 
 
     function RowSelected(row, eventArgs) {  
        
         var grid = $find("<%=RadGridService.ClientID %>").get_masterTableView();  
         grid.rebind();  
      
 
     }   
 </script> 
</telerik:RadCodeBlock> 




<telerik:RadGrid ID="RadGrid1" AllowSorting="True" AllowPaging="True" 
            AutoGenerateColumns="False" runat="server" GridLines="None" Width="653px"   
            onneeddatasource="RadGrid1_NeedDataSource" > 
              
                <MasterTableView> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="ID" HeaderText="ID" DataType="System.Int32" /> 
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" /> 
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" /> 
                             </Columns> 
            </MasterTableView> 
            <PagerStyle AlwaysVisible="true" /> 
            <ClientSettings EnablePostBackOnRowClick="True" > 
              
              
                <ClientEvents OnDataBinding="RadGrid1_DataBinding" /> 
 
              
                <DataBinding Location="Services.asmx" 
                    SelectMethod="GetData" SelectCountMethod="GetCount" /> 
                <Selecting AllowRowSelect="True" /> 
              
              
                 <ClientEvents OnRowSelected = "RowSelected"/>  
 
              
            </ClientSettings> 
        </telerik:RadGrid> 

At the bottom of the form, I have a button to post the results of the client-side selection.  How can I retrieve the results of the client-side selection on the server postback?

I have attempted the following code, but text returns "&nbsp;".  If the Grid has no selection, the SectedItems count is 0 and if one item is selected the count is 1, but I am not sure how to retrieve the PrimaryKey or cell from the selected item.

 protected void Button1_Click(object sender, EventArgs e)     
        {     
           GridItemCollection selectedItems = RadGrid1.SelectedItems;     
           foreach (GridItem selectedItem in selectedItems)     
            {     
              string text = ((GridDataItem)selectedItem)["LastName"].Text;     
                                   
            }                  
        }     
 

Any ideas what I am missing?
Georgi Krustev
Telerik team
 answered on 08 Jul 2009
1 answer
351 views
Hi,

RadGrid and  Export to Excel, all columns are not exporting to Excel file, some columns are missing while exporting but it working fine in some other page Below is the code for Export to Excel.

        grid1.DataSource = ViewState("OrderHeader")
        grid1.DataBind()
        grid1.ExportSettings.FileName = "OrderSummary"
        grid1.ExportSettings.IgnorePaging = True
        grid1.ExportSettings.OpenInNewWindow = True
        grid1.HeaderStyle.Font.Bold = True
        grid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML
        grid1.ExportSettings.ExportOnlyData = True
        grid1.MasterTableView.ExportToExcel()

Any help would be appreciated. Please help me out.

Thanks
Durga
Computer Surgeon
Top achievements
Rank 1
 answered on 08 Jul 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?