Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
198 views
hi
I've got an radgrid with edit/delete/insert features enabled on. editmode for the grid is set to popup. I'd like to know How can I alter edit window's Update/Cancel buttons captions' to some other langueage ( destination language is Persian(Iran)) . Perferebly I would enjoy setting some properties to write my own stuff.

thanks for upcomming replies.
With Kind Regards
wnl
Top achievements
Rank 1
 answered on 10 Feb 2011
1 answer
138 views
Hi,

I have upgraded the telerik controls version from 2010.3.929.35 to version 2010.3.1317.35.

In Current version(2010.3.1317.35), when we copy the content from word document and Paste the clipboard data to Radeditor control by only Paste command(Not the Paste from word, only using Paste (CTRL +V)),  
Then after by showing the HTML view or Preview the content, the actual view which is pasted is lost and all are goes left aligned, and aslo STYLE attribut from page also removed.

And also Disableing the ConvertToXhtml  is not working.

This above problem is not happening in Previous version (2010.3.929.35).
 
Please see the attached screen shot.

Vijay
Dobromir
Telerik team
 answered on 10 Feb 2011
1 answer
76 views
Hi,

I'm building a grid dynamically from several database tables. 
Tables: 
* Groups (used to group columns)
* Columns

And datatables, to support data in the structure.

One column can only be member of one group.. but a group can contain several columns.
In the Grid this will be viewed with two column headers, where the group header uses columnspan to span over the columns within the group.
A column contains datatype, format, width and alignment.
So far so good... 

I managed to create a grid looking like it should with the column headers and groupheaders. I used the PreRender event to add a second header.

I also added all necessary data to the extendedproperties on the datatable (the datatable is dynamically buildt to support the dynamic setup). So this would be available for me when rendering the grid.

But my problem starts when i wanted to format the data within the cells/columns. One of the column had the type DateTime and the format "{0:dd.MM}" (want to show day and month only). I tried to set the DataFormatString in the PreRender Event for the column, but it still shows the whole date and time. 
How can i solve this? This is the code i hardcoded into the prerender event to test this: 
((GridBoundColumn)RadGrid1.MasterTableView.GetColumn("to.date")).DataType = Type.GetType("System.DateTime");
((GridBoundColumn)RadGrid1.MasterTableView.GetColumn("to.date")).DataFormatString = "{0:dd.MM}";

I'm not able to set the alignment for the column either. I can set it for the columnheaders, but i think that is because i have the cell object for each header. I want to be able to set both the format and the alignment for the column some place...

Some of the columns can have a flag saying that if the value drops below zero we want to display zero or blank. Is there anywhere this can be set. And remember, i don't know the name of the column before runtime.

And one other thing: How can i add a "grand total" row at the end summarizing only the columns marked for it? (eg: column3, column4 and column5 should be summarized, but not column1 and column2).



Regards
Svein Thomas
Radoslav
Telerik team
 answered on 10 Feb 2011
0 answers
109 views
Working with 2008.2.1001.35

Main Idea : provide the ability to multi select values in radcombobox but allow to loadondemand
Secondary : update the number of selected item, current text is the first selected item in radcombobox

Main problem : on item request, we cannot get selected item"s".

Workaround :

Part 1 : implementing multi select and loadOnDemand at the same time
Tricky parts : rebind each item after getting datasource, binding values are Text and Value (names of radcomboboxitem), which are not the names in the datasource's header.

Aspx
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
[...]
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
         function StopPropagation(e) {
                e.cancelBubble = true;
                if (e.stopPropagation) {
                    e.stopPropagation();
                }
  
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
  
                var combo = $find("<%= multiselectTitle.ClientID %>");
                var newText = "";
                var cnt = 0;
                var items = combo.get_items();
                var first = false;
                var firstItem = "";
                for (var i = 0; i < items.get_count(); i++) {
                    var item = items.getItem(i);
                    var checkbox = item.get_element().getElementsByTagName("input")[0];
                    if (checkbox.checked) {
                        if (first == false) {
                            firstItem = item.get_text();
                            first = true;
                        }
                        newText += item.get_value() + ";";
                        cnt++;
                    }
                }
  
                ajaxManager.ajaxRequest(newText);
                combo.set_value(newText);
                combo.set_text(firstItem);
  
                document.getElementById("ctl00_contentPlaceHolder_div_count").innerHTML = cnt;
            }
[...]
  
<div id="div_count" runat="server">0</div>
  
[...]
  
<telerik:RadComboBox ID="multiselectTitle" runat="server" EnableLoadOnDemand="true" AutoPostBack="false" DataTextField="Title" DataValueField="Id" OnItemsRequested="multiselectTitle_ItemsRequested">
    <ItemTemplate>
        <div id="div1" onclick="StopPropagation(event)">
            <asp:CheckBox ID="chkBoxPrdTitle" runat="server" value='<%# DataBinder.Eval(Container, "Value") %>' />
                <asp:Literal ID="litPrdTitle" runat="server" Text='<%# DataBinder.Eval(Container, "Text") %>'></asp:Literal>
        </div>
    </ItemTemplate>
</telerik:RadComboBox>
  
[...]


Code behind
private void resetSelectedPrdIds()
    {
        Session["selectedPrdIds"] = null;
        div_count.InnerHtml = "0";
        multiselectTitle.Text = "";
    }
  
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            resetSelectedPrdIds();
        }
    }
  
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        string[] values = e.Argument.Split(';');
  
        List<int> ids = new List<int>();
        foreach (string value in values)
        {
            try { ids.Add(int.Parse(value)); }
            catch { }
        }
        Session["selectedPrdIds"] = ids;
    }
  
  
    protected void multiselectTitle_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox comboBox = (RadComboBox)sender;
  
        List<int> selectedPrdIds = new List<int>();
        if (Session["selectedPrdIds"] != null)
            selectedPrdIds = (List<int>)Session["selectedPrdIds"];
  
        var itemObjects = from items in myDataContext
                                         where (SqlMethods.Like(items.title, e.Text + "%") || 
                                                     (from vals in selectedPrdIds select vals).Contains(items.id))
                                         select new { Id = items.id, Title = items.title };
  
        foreach(var io in itemObjects)
        {
              comboBox.Items.Add(new RadComboBoxItem(io.Title, io.Id.ToString()));
        }
  
        RadComboBoxItemCollection rcbic = multiselectTitle.Items;
        foreach (RadComboBoxItem item in rcbic)
        {
            if (selectedPrdIds.Contains(int.Parse(item.Value)))
            {
                ((CheckBox)item.FindControl("chkBoxPrdTitle")).Checked = true;
            }
            item.DataBind();
        }
    }


Feel free to comment above code

joa
Patrick Anthamatten
Top achievements
Rank 1
 asked on 10 Feb 2011
3 answers
79 views
Hello,

Would this code work?

dim rs1 as new radscheduler
rs1.visible = true
rs1.enabled = true

I am trying to create multiple instances of RadScheduler on the fly.
Peter
Telerik team
 answered on 10 Feb 2011
1 answer
80 views
We have just started converting all of our asp:textbox to telerik:radTextBox. We created a standard css file (used for all aspx pages) so we could set the width's for different boxes based on usage. Example, a box for state only needs to be 2 characters wide (about 20-30px). The skin manager overrides the cssclass property setting for the telerik boxes, setting all boxes to the same width. How can I still use a custom style sheet to set width's and the skinmanager at the same time?
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
4 answers
91 views
Hello,

I have a form with a RadScriptManger, RadAjaxManager, and RadGrid.

One of the columns of the RadGrid loads a dynamic linkbutton that I want to pop-up an Open/Save File Dialogue box.  It works without the RadAjaxManager, but with it I get this error:

Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Which is correct, I subscribe each dynamic link button to the following click event that modifies the Response,
Protected Sub onClick(ByVal sender As Object, ByVal e As EventArgs)
  
        Try
  
            Dim NewButton As LinkButton = CType(sender, LinkButton)
  
            Dim con As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("NBOConnectionString").ConnectionString)
            Dim cmd As New SqlClient.SqlCommand("Select Id, NDAId, FileName, [File], FileType FROM NDA_Files Where Id = " & Convert.ToInt32(NewButton.ToolTip), con)
            Dim da As New SqlClient.SqlDataAdapter(cmd)
  
            con.Open()
  
            Dim dt As New Data.DataTable
  
            da.Fill(dt)
  
            For Each row As Data.DataRow In dt.Rows
                With row
  
                    Dim DataFile() As Byte
                    DataFile = .Item("File")
                    HttpContext.Current.Response.Buffer = True
                    HttpContext.Current.Response.ContentType = .Item("FileType")
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" & .Item("FileName"))
                    HttpContext.Current.Response.AppendHeader("Content-Length", DataFile.Length.ToString())
                    HttpContext.Current.Response.BinaryWrite(DataFile)
  
                End With
            Next
                    Catc

I searched around and found this article:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx

Towards the bottom of that, there is this solution:
Call ScriptManager.RegisterPostBackControl() and pass in the button in question. This is the best solution for controls that are added dynamically, such as those inside a repeating template.

I didn't see "RegisterPostBackControl()" within the RadScriptManager so I added .NETs script manager and added a section in my RadGridItemDataBound procedure to add the dynamic linkbuttons to this as show below:
For Each Control In e.Item.Controls
                       If CType(Control, Telerik.Web.UI.GridTableCell).Controls.Count > 2 Then
                           If CType(Control, Telerik.Web.UI.GridTableCell).Controls(1).GetType.Name = "LinkButton" Then
                               Dim lnkButton As LinkButton = CType(CType(Control, Telerik.Web.UI.GridTableCell).Controls(1), LinkButton)
                               ScriptManager1.RegisterPostBackControl(lnkButton)
                           End If
                       End If
                   Next

Which finds the LinkButtons and adds them with no errors.....However when I click the linkbutton I still get the error.
Is there any better way to get this functionality?

Either I need to figure out how to exclude the linkbuttons from the AJAX call, or a way to make the pop-up work without using the Response.  Any Ideas?

Thanks,

Coty



Pavlina
Telerik team
 answered on 10 Feb 2011
4 answers
149 views
Hi

I need to set overflow: visible on a textbox but have found that the style is not being obeyed.

I modified a Telerik example page by adding a textbox to the page with the overflow property set:

<li>
      test : <input type="text" value="message" style="overflow:visible;width:20px" />
</li>

I have attached a screenshot of what I see.

I am using RadControls for ASP.NET AJAX Q3 2010 and I see the problem in IE8 and FireFox 3.6.

Any help is appreciated.
TheCroc
Top achievements
Rank 1
 answered on 10 Feb 2011
1 answer
102 views
I am using date range filter from this example

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx it has 2  datepickers for From and To.

I want to add also regular filter or date picker fo this column too.Otherwise, how do i filter just the date not date range?
Just found this post
http://www.telerik.com/community/forums/aspnet-ajax/grid/filter-with-from-and-todate-for-datetime-colum-with-normal-datepicker-filter.aspx

Dont think it provides elegant solution


Thank

Alex
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
1 answer
143 views
When using RadGrid's WebUserControl, the DataItem object becomes null when using an ObjectDataSource only to fill ListBox.

Scenario 1 Works - Calling DataSource = __ and DataBind() in Page_Load:

protected void Page_Load(object sender, EventArgs e)  
{
    lstItemCollection.DataSource = GetCityCollection();
    lstItemCollection.DataBind();
}
public IEnumerable<Customer> GetCityCollection()
{
    using (UowEntities uow = new UowEntities())
    {
        CustomerRepository cr = new CustomerRepository(uow);
        return cr.SelectAll().ToArray();
    }
}
<asp:ListBox ID="lstItemCollection" runat="server" SelectionMode="Multiple" 
    DataValueField="CustomerId" DataTextField="City"  />

Scenario 2 - DataItem object is null when needed if using ObjectDataSource to bind data to ListBox:

<asp:ListBox ID="lstItemCollection" runat="server" SelectionMode="Multiple" DataValueField="CustomerId" DataTextField="City" DataSourceID="odsCityCollection" />           
<asp:ObjectDataSource ID="odsCityCollection" runat="server" SelectMethod="GetCityCollection"
TypeName="LINQScratchPad.Web.CommonUserControls.CustomerControl" ></asp:ObjectDataSource>

The ObjectDataSource automatically calls the GetCityCollection() method and that is when the DataItem becomes null. Later in the page lifecycle it will have a value again until I force the ListBox to DataBind in attempt to see if I have a value to DataItem (or even access to a HiddenField for that matter!).  I want the CustomerId value to filter my query in the SelectMethod of the ObjectDataSource. **NOTE: this is a very simple example and not real-world as I have moved to a play project for testing to resolve the underlying issue of a null DataItem.** I added the PreRender event handlers to show I have access to the DataItem again after it had become null.

public partial class CustomerControl : System.Web.UI.UserControl
{
    private object _dataItem;
    public object DataItem
    {
        get { return this._dataItem; }
        set { this._dataItem = value; }
    
    protected void Page_Load(object sender, EventArgs e)  {  }

    public IEnumerable<Customer> GetCityCollection()
    {
        using (UowEntities uow = new UowEntities())
        {
            Customer foo = (Customer)DataItem; // Always null!
              
            // Will throw null reference exception here if uncommented
            //var bar = HiddenField1.Value; 
            CustomerRepository cr = new CustomerRepository(uow);
            return cr.SelectAll().ToArray();
        }
    }
      
    protected void Page_PreRender(object sender, EventArgs e)
    {
        Customer foo = (Customer)DataItem; // Has value here
        var bar = this.HiddenField1.Value; // Has value here
        lstItemCollection.DataBind(); // DataItem is now null again :(
    }
    protected override void OnPreRender(EventArgs e)
    {
        Customer foo = (Customer)DataItem; // Has value here
        var bar = this.HiddenField1.Value; // Has value here
        lstItemCollection.DataBind(); // DataItem is now null again :(
        base.OnPreRender(e);
    }
}

In watching the DataItem value throughout the page lifecycle process, this is what I observed:
Page_Load - DataItem has value.  {F10}
Sets my HiddenField value. {F10}
<asp:HiddenField Value='<%# Eval("CustomerId") %>'  ID="HiddenField1" runat="server" />
Sets my other two Binds. {F10}
<ol class="column1">
    <li>
        <asp:Label ID="lblFirstName" runat="server">First Name:</asp:Label>
        <asp:TextBox ID="txtFirstName" runat="server"  Text='<%# Bind("FirstName") %>' />
    </li>
    <li>
        <asp:Label ID="lblLastName" runat="server">Last Name: </asp:Label>
        <asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>' />
    </li>
</ol>
ObjectDataSource calls GetCityCollection() and now DataItem object is null.

After that when stepping into the PreRender the DataItem has a value again until calling ListBox.DataBind() where the ObjectDataSource steps into the GetCityCollection() method and DataItem is once again null.

Can anybody explain why DataItem becomes null please?  
Thanks in advance!!
-Carrie
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?