Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
63 views
Please delete, an error occurred during posting.
Seth
Top achievements
Rank 1
 asked on 13 Sep 2010
1 answer
124 views

Hi friends

can i use telerik:RadAsyncUpload without any skin just like asp:FileUpload for more consistent with page skin that Css uses?

Genady Sergeev
Telerik team
 answered on 13 Sep 2010
1 answer
114 views
In one table I have three zones (left mid and right). In other table I have two zones, one of which is a two column zone (per say). I need these zones to align on collapse. It seems that this only works properly in the same zone with a three column layout.

See linked image. Notice the large gap. How can I get rid of this space?

http://i55.photobucket.com/albums/g121/Farsight38/raddockzone.jpg
Pero
Telerik team
 answered on 13 Sep 2010
4 answers
135 views
Hi guys,

I'm having a lot of troubles using ASP.Net WebForms 4   Route Urls   Telerik ASP.NET AJAX Controls version 2010 Q2 826.

Problems that i'm facing are:

- Ajax RadControls are losing all the Layout and Effects;
- RadTextBoxes are losing the text value on the code-behind.

What do i need to do to solve these problems? Please Help me!!!

PS.: When i remove the urls route all the problems disappear.

Thanks a lot!!!
Rodrigo
Top achievements
Rank 1
 answered on 13 Sep 2010
1 answer
135 views
I am trying to do something like the Hierarchy Template demo,

http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx

In the inner multi-tab views, I'd like to have Insert/Update/Delete than just viewing. When I followed the example to save the 'parent' primary key (ID) into a label control, it turned out that Delete/Update work, but to add a new record will trigger a key conflict error in SQL. I used SQL Profiler to trace it and found that the sql statement has '0' for the ID field (it's an identity field).

Please help.

and also, why that example uses label control to save the parent primary key, instead of using ParentTableRelation?
Iana Tsolova
Telerik team
 answered on 13 Sep 2010
1 answer
221 views

Requirements

RadControls version

Q1 2009+

.NET version

3.5

Visual Studio version

2008

programming language

C#

browser support

all browsers supported by RadControls


A generic method for Custom Sorting in RadGrid using LINQ

I imagine that if you've found yourself needing to apply custom sorting in a RadGrid, you started, like me, by looking at the XXXXXXX custom sort pages in the RadGrid documentation. Like me you may have wondered if you needed to code for each of the sort options in your grid.

I found myself needing to allow sorting in a grid that

  • got it's data from a WCF service, and
  • paged the data (which could, potentially, run to thousands of records)

The grid itself had a large number of columns and the requirements document said that the grid had to

  • allow multi-column sorting,
  • allow natural sorting, and
  • allow for the provision of a default sort column.

 
My first aim was to work out how I might code to sort on any number of columns in a multi-column table. A bit of googling turned up this stack overflow article which, in turn led me to this code snippet on http://aonnull.blogspot.com/. Adam's code provides an extension to the IEnumerable and IQueryable types that allows the developer to pass in a string representation of a search criterion and have it transformed in to Linq.

So, my next aim was to get RadGrid, when I opt to sort a grid, to provide me with a representation of the sort criteria that I could use in Adam's code.

This turned out to be a little less than trivial because whilst all of this info is available via certain RadGrid properties, it's not in one place.

The upshot was that I needed, and so created a set of helper methods (which could, I'm sure with just a little effort, be tranmsformed in to extension methods on the GridTableView object).

These helper methods are shown below.

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using Telerik.Web.UI;
using System.Web.UI.WebControls;
  
public static class RadGridHelper
{
    public static string GenerateOrderByExpression(GridTableView RadGridTableToSort, GridSortCommandEventArgs SortCommandArgs)
    {
        if (RadGridTableToSort.AllowMultiColumnSorting)
        {
            return GenerateMultiColumnExpression(RadGridTableToSort, SortCommandArgs);
        }
        else
        {
            return GenerateSingleColumnExpression(RadGridTableToSort, SortCommandArgs);
        }
    }
  
    static string GenerateMultiColumnExpression(GridTableView RadGridTableToSort, GridSortCommandEventArgs SortCommandArgs)
    {
        List<GridSortExpression> sort = new List<GridSortExpression>();
        foreach (GridSortExpression x in RadGridTableToSort.SortExpressions)
        {
            sort.Add(new GridSortExpression{ FieldName = x.FieldName, SortOrder = x.SortOrder });
        }
  
        GridSortExpression sortExp = sort.FirstOrDefault(exp => exp.FieldName == SortCommandArgs.SortExpression);
        if (sortExp != null)
        {
            if (SortCommandArgs.NewSortOrder == GridSortOrder.None)
            {
                sort.Remove(sortExp);
            }
            else
            {
                sortExp.SortOrder = SortCommandArgs.NewSortOrder;
            }
        }
        else
        {
            if (SortCommandArgs.NewSortOrder != GridSortOrder.None)
            {
                sort.Add(new GridSortExpression{ FieldName = SortCommandArgs.SortExpression, SortOrder = SortCommandArgs.NewSortOrder });
            }
        }
        return GetSortExpressionString(sort);
    }
  
    static string GenerateSingleColumnExpression(GridTableView RadGridTableToSort, GridSortCommandEventArgs SortCommandArgs)
    {
        string defaultSortExpression = GetDefaultSortColumn(RadGridTableToSort);
  
        // if the sort order is null, return the default sort order.
        if (SortCommandArgs.NewSortOrder == GridSortOrder.None)
        {
            return String.IsNullOrEmpty(defaultSortExpression) ? String.Empty : GetSortExpressionString(new GridSortExpression { FieldName = defaultSortExpression, SortOrder = GridSortOrder.Ascending });
        }
  
        GridSortExpression newExplicitSortExpression = new GridSortExpression { FieldName = SortCommandArgs.SortExpression, SortOrder = GridSortOrder.Ascending };
        if (String.IsNullOrEmpty(defaultSortExpression))
        {
            return GetSortExpressionString(newExplicitSortExpression);
        }
        else
        {
            return GetSortExpressionString(new List<GridSortExpression>
            {
                newExplicitSortExpression,
                new GridSortExpression { FieldName = defaultSortExpression, SortOrder = GridSortOrder.Ascending }
            });
        }
    }
      
  
    static string GetSortExpressionString(GridSortExpression SortExpression)
    {
        if (SortExpression == null)
        {
            return String.Empty;
        }
        return String.Format("{0} {1}", SortExpression.FieldName, SortExpression.SortOrderAsString());
    }
  
    static string GetSortExpressionString(List<GridSortExpression> SortExpressions)
    {
        StringBuilder sb = new StringBuilder();
        bool first = true;
        SortExpressions.ForEach(exp =>
                                {
                                    if (first)
                                    {
                                        first = false;
                                    }
                                    else
                                    {
                                        sb.Append(", ");
                                    }
  
                                    sb.Append(GetSortExpressionString(exp));
                                });
        return sb.ToString();
    }
  
    static string GetDefaultSortColumn(GridTableView RadGridTableToSort)
    {
        string retValue = String.Empty;
        WebControl c = RadGridTableToSort as WebControl;
        if (c.HasAttributes && !String.IsNullOrEmpty(c.Attributes["DefaultColumnSortExpression"]))
        {
            retValue = c.Attributes["DefaultColumnSortExpression"];
        }
        return retValue;
    }
}

The GenerateOrderByExpression method, the only public method in the class, returns a string representation of the requested sorting of the grid. This method is required 'cos the SortCommand event arguments only give you the details of the column being sorted on now. This is OK if AllowMulticolumnSorting="false", but if it is true, there's nothning to tell you anything about the other columns being sorted on.

The GenerateOrderByExpression method calls one of 2 other methods depending on whether the RadGrid table is defined for multicolumn sorting or not.

However, before we look at these 2 methods, let's consider the concept of a default sort column. My requirements document said that a grid will display data in the order of a named column unless a different order is specifically set by the user and then, the sorted data will, where duplicates in the sorted column(s) exist, be sorted by the named default column. What this means is that regardless of what sort order the user selects, the data will /also/ be sorted by the named default column. In practice, this meant checking that the user wasn't sorting by the default column but in a different order and adding the default column (with a sort direction of ASC) to the end of any sort expression.

The methods GenerateMultiColumnExpression() and GenerateSingleColumnExpression() both create a string in the format "ColumnName ASC|DESC[, [...]]" which is passed via the WCF services to the Data Access Layer where the pre-existing Linq-to-Sql was modified to include a called to Adam's OrderBy() extension method.

A couple of things to note. I wrote the RadGrid helper methods to take a GridTableView as a parameter so that the code could be called for both the RadGrid's MasterTableView and any DetailTables. The Default Sort Order attribute is defined using the fact that the GridTableView is descended from a WebControl. You need to be sure that your code, specifically in your DAL takes into account that the supplied OrderBy parameter may be an empty string.

Finally, below, is a simple example of using the helper methods and Adan's extension method in a single tier app's SortCommand event handler.

protected void RadGrid1_SortCommand(object sender, GridSortCommandEventArgs e)
{
    string orderbyExpression = GenerateOrderByExpression(e.Item.OwnerTableView, e);
    e.Item.OwnerTableView.DataSource = data.OrderBy(orderbyExpression);
    e.Item.OwnerTableView.Rebind();
}

Veli
Telerik team
 answered on 13 Sep 2010
1 answer
174 views
Hi There,

Below is my sample code of a GridTemplateColumn in RadGrid1.
To be noted that there are 2 labels, for displaying MYR and USD amounts respectively, in the footer.
<telerik:GridTemplateColumn UniqueName="Balance" HeaderText="Balance">
    <ItemTemplate>
        <asp:Label ID="lblBalance" runat="Server"></asp:Label>
    </ItemTemplate>
    <FooterTemplate>
        <asp:Label ID="lblBalanceMYR" runat="Server"></asp:Label
        <asp:Label ID="lblBalanceUSD" runat="server"></asp:Label>
    </FooterTemplate>
</telerik:GridTemplateColumn>

I try to use below javascript to retrieve the MYR amount for further client-side validation. Unfortunately the program always throws me the USD amount, a.k.a. the inner text of "lblBalanceUSD" only, instead of "lblBalanceMYR".
var Amount = RadGrid1.get_masterTableView().get_element().tFoot.all.tags("span")[0].innerHTML;

Any idea to access the text of "lblBalanceMYR"?
Thanks in advance. :)
Shinu
Top achievements
Rank 2
 answered on 13 Sep 2010
1 answer
68 views
Hi!

We think we have an issue with the image map manager. If you edit an image map, adds a region and the clicks Ok sometimes the html doesn´t get the link, just the region. If you click update and then Ok it seems to work, if you add a circle is seems to work also. Is this expected behaviour?

We are currently using Q1 2010 release and the issue appears on your demo site as well.

Kind Regards /David
Dobromir
Telerik team
 answered on 13 Sep 2010
3 answers
183 views
Hi Guys,

I have RadToolBar as a user control like

HeaderToolBar HTML:
<telerik:RadToolBar ID="barTopCommandBar" runat="server" Height="26px" Width="100%" OnButtonClick="barTopCommandBar_ButtonClick">
    <Items>
        <telerik:RadToolBarButton  runat="server" CommandName="ADD"  ImageUrl="~/Images/TLB_SAVE_16.gif" Text="SAVE">
         </telerik:RadToolBarButton>
 </Items>
</telerik:RadToolBar>

Code Behind:

 public delegate void SaveDelegate(object sender, RadToolBarEventArgs e);
 public event SaveDelegate Save_Event;

 protected void barTopCommandBar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
  {
            switch ((e.Item as RadToolBarButton).CommandName)
            {
                    case "SAVE":
                    Save_Event(sender, e);
                    break;
     }
  }

Now i have Contenet Page:
in this page i have Maltiview Page which have some views like View1,View2......etc.

<%@ Register Src="~/ViewControls/HeaderToolBar.ascx" TagPrefix="uc" TagName="HeaderToolBar" %>
        protected void Page_Init(object sender, EventArgs e)
        {
         HeaderToolBar1.Save_Event += new WFSite.ViewControls.HeaderToolBar.SaveDelegate(HeaderToolBar1_Save_Event);
         }
********************
 void HeaderToolBar1_Save_Event(object sender, RadToolBarEventArgs e)
        {

            switch (MultiView1.ActiveViewIndex)
            {
                case 0:
                    // Doing some
                    break;
            }
      }

Now my question.... how to do parital update view1 (view1 is inside the asp.net panel like pnlView1) using RadAjexManager with AjaxSettings and RadAjaxLoadingPanel1 programmatically in code behind.

Thanks
Ravi 


Iana Tsolova
Telerik team
 answered on 13 Sep 2010
3 answers
93 views

Hi
Am new with rad controls. i want to register rad panel bar control in the master page for navigation. My solution uses Web client software factory platform. Any help will be of greet importance

Derrick
Nikolay Tsenkov
Telerik team
 answered on 13 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?