Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
90 views
I have a RadGrid with using AllowAutomaticUpdates and EntityDataSource and I'd like to set some custom data (or override data) before the item is saved.

How do I do this?

I've tried this, but it doesn't work:

protected void rgUnits_UpdateCommand(object sender, GridCommandEventArgs e)
       {
           GridEditableItem item = (GridEditableItem)e.Item;
           ((RadDatePicker)item["LastModified"].Controls[0]).SelectedDate = DateTime.Now; 
           ((TextBox)item["LastModifiedBy"].Controls[0]).Text = Context.User.Identity.Name;
       }

<telerik:GridDateTimeColumn DataField="LastModified" FilterControlAltText="Filter Last Modified" HeaderText="Last Modified" SortExpression="LastModified" UniqueName="LastModified" ReadOnly="true" AllowFiltering="true" ColumnEditorID="gceSmallDateBox" DataFormatString="{0:dd/MM/yyyy}" PickerType="DatePicker">
                                            </telerik:GridDateTimeColumn>
                                            <telerik:GridBoundColumn DataField="LastModifiedBy" FilterControlAltText="Filter Last Modified By" HeaderText="Last Modified By" SortExpression="LastModifiedBy" UniqueName="LastModifiedBy" ReadOnly="true" AllowFiltering="true">
                                            </telerik:GridBoundColumn>


I don't *need* to have them as Grid Columns, but I figured this is what I'd have to do to get it work.
Peter
Top achievements
Rank 1
 answered on 10 Dec 2012
14 answers
229 views
Hi,

I'm having a problem with the RadGrid and using StaticHeader. When UseStaticHeaders="true", the header and footer get a margin-right of 17px (the size of the vertical scrollbar). This results in an empty/white space next to the footer/header. However, if I decrease the page size to 10, the scrollbar disappears. Now, the margin from the header is removed and gets the full width of the grid. But the margin is not removed from the footer.

Steps to reproduce:

Markup:
<telerik:RadGrid ID="grdData" runat="server" PageSize="20" AllowPaging="true" ShowFooter="true" OnNeedDataSource="grdData_NeedDataSource">
    <ClientSettings>
      <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" />
      <Resizing ClipCellContentOnResize="false" AllowColumnResize="true" AllowResizeToFit="true" EnableRealTimeResize="true" />
    </ClientSettings>
    <MasterTableView AutoGenerateColumns="true">
    </MasterTableView>
  </telerik:RadGrid>

Code behind:
public partial class test : System.Web.UI.Page {
    public class MyDataItem {
      public int Id { get; set; }
      public string Name { get; set; }
    }
 
    protected void Page_Load(object sender, EventArgs e) {
       
    }
 
    protected void grdData_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) {
      List<MyDataItem> datasource = new List<MyDataItem>();
      for (int i = 0; i < 100; i++) {
        datasource.Add(new MyDataItem() {
          Id = i,
          Name = "name_" + i
        });
      }
 
      grdData.DataSource = datasource;
    }
  }

On initial load, the page size is 20 and the vertical scrollbar, including the whitespaces, it rendered.
Now reduce the pagesize to 10: the vertical scrollbar is gone but the whitespace next to the footer remains.

In this example in doesn't look like a problem (besides it doesn't look nice). However, I'm having a grid with 20 columns and values in the footer. The last value can't be read completely because half of the text is cut of due to the margin.

Is this realy a bug or am I doing something wrong? And is there any workaround?

Thanks.
Pavlina
Telerik team
 answered on 09 Dec 2012
1 answer
107 views
hello,
I' m new in raddevelopment and I'm trying the free Telerik's version
For some reason, I put the radMenu control in an ascx asp.net control and the ascx control is in a masterPage
The basic functions of the menu are working well
But the calling pages are heavy, and it takes several secondes/ minutes to load.
I need to put a waiting message onload
In a normal aspx page, I put the radMenu in an updatepanel, with a updateprogress and there isn't ny problem
But,in the mentioned situation, I tried onclick, onitemclick, onitemdatadound, and every onclient function. I won't be able to fire any waiting message.
Do you have some idea?
Thank you
Pierre
Top achievements
Rank 1
 answered on 09 Dec 2012
3 answers
143 views
My basic question is, every time the Count changes during client-side data binding, it jumps me back to the first page.  Is there any way to prevent this?

Here's a more in-depth description of the problem:

I'm using the RadGrid to display messages with client-side data binding.  A new message arrives on the server every few seconds.  We only keep x hundred messages on the server so once the queue is full old messages fall off the queue as new ones arrive.  Therefore using the standard startRowIndex to keep track of where we are in the grid doesn't work for us.  What is row 20 in one call might be row 19 a few seconds later as the oldest message falls off the queue.  Therefore simply want the next/previous/first/last buttons to jump to the next/previous/first/last group of messages and I'll handle the paging logic with my server code.

Toward that end, I have overridden (using OnItemCreated) the next/previous paging buttons to call my own javascript function for paging -
    function myGridPage(radGridId, dir) {
        pagingDirection = dir;
        $find(radGridId+'_ctl00').page(dir);
    }

Then on data binding I do this:
function RadGridMessages_DataBinding(sender, args) {
        var myMethodArguments = new Object();
        myMethodArguments.pagingDirection = pagingDirection;
        myMethodArguments.maximumRows = args.get_methodArguments().maximumRows;
        args.set_methodArguments(myMethodArguments);
    }

On the server-side I do this:
        [WebMethod(EnableSession = true)]
        public Dictionary<string, object> GetMessages(string pagingDirection, int maximumRows)
        {
<message logic goes here>
            Dictionary<string, object> data = new Dictionary<string, object>();
            data.Add("Data", messages);
            data.Add("Count", totalNumberOfMessages);
            return data;
        }

Everything seems to work fine, except that the "Count" changes often during the first few hours before the server message queue is full.  Every time the Count changes the Telerik client-side code calls set_virtualItemCount() which calls set_currentPageIndex(0).  This move me back to the first page (and triggers a rebind).

a. Am I handing the next/previous page in an appropriate way for my situation or is there a better way to do this.
b. How do I prevent set_virtualItemCount() from kicking me back to the first page every time the count changes?


Amjad
Top achievements
Rank 1
 answered on 09 Dec 2012
0 answers
113 views
Hi Team,

I have very peculiar process.

I am adding in my page on code-behind in the Init of the page a Radcombobox with a dynamic ID. Furthermore I am adding a RadtreeView to it on codebehind with a fix id and with only one node

using this idea:
...
 public void InstantiateIn(Control container)
        {
            RadTreeView tree = new RadTreeView();
            tree.ID = "tv";
            tree.CheckBoxes = true;
            tree.ExpandAllNodes();
            container.Controls.Add(tree);

...

Now my big deal is I want to load that RadTreeView on demand and client-side . My problem came with the JavaScript that is not fiding the controls that have been added on the code behind

I try to add on the load page using a RadCodeBlock the script to find the control but it is not working. Also I tried Sys.Application.add_load(ale)


something like this:
System.Text.StringBuilder sb = new System.Text.StringBuilder();     
            sb.Append(@"<script language='javascript'>");
            sb.Append(@"Sys.Application.add_load(ale);");
            sb.Append(@"alert('Hello World');");
            sb.Append(@"var comboBOX = document.getElementById('<%= 2.ClientID %>'); ");
            sb.Append(@"function ale(){alert(comboBOX);}");
            sb.Append(@"</script>");

Could you help me with an example or some guidance to get the ComboBox that I loaded dynamically with a dynamic ID on Java Script or JQuery. When I get the comobo box how the treeview has a predefined ID I will be able to get it on client-side.

Thank you
            LiteralControl literaJS = new LiteralControl(sb.ToString());
            RadCodeBlockFilterControl.Controls.Add(literaJS);
Denis
Top achievements
Rank 2
 asked on 09 Dec 2012
0 answers
94 views
Hello,
 I am using RadAjaxLoadingPanel to show progress bar on button click. I want to display on page based on id of control. I am using following code to remove background image from class.

  .RadAjax_Office2007 .raDiv
        {
            background-imageurl('') !important;
        }
And on id of control i am showing it like this
    #RadAjaxLoadingPaneldivVital
        {
            background-imageurl("WebResource.axd?d=WSBu9pOMHRl15KsTHWg3T0kmn2YGmMPVvRl2sILKsHrpfxNvrCzaIJl2lpa7x1j9jZKMpkIrN3swdVxt4LudmphTXALh-aA69uNkfQVAWlhNswKa8jAvmaqGRuXJBGaAwBDq-kckfrv9OfQ-kKQJYN2w2wnXp57-m4HO_IOBKP3wUlVUudTpfi9hzwtW4ZIkLXeV2RjIa9Dejcjy16e-mQ2&t=634642303574596967") !important;
            background-repeatno-repeat;
            background-positioncenter;
        }
It woks fine on my machine and progress bar is displaying on page. but on other machine it is not displaying. When i am figuring out using
fire bug it is showing that image is failed to load. I thing each machine generate different background image url. So how I will
use background image url which will be same for all machines.
Ranjan
Top achievements
Rank 1
 asked on 08 Dec 2012
0 answers
121 views

problem in left & ritgh Margin of the windows
Example photos in attach file
plz help me
komeil
Top achievements
Rank 1
 asked on 08 Dec 2012
4 answers
432 views
Hello,

I have a grid with a custom form template that I use for editing.  Inside the template are dropdownlists and textboxes and I see that there aren't any events that I can use when these controls are in the form template.  Is there a way to force an event like selectionIndexChanged or textChanged and if not what event in the grid can I use to manipulate these contols when a user does perform a textChange or selectionIndexChage?

Thanks,
Kirk
Atlas
Top achievements
Rank 1
 answered on 08 Dec 2012
6 answers
313 views
Hi!

I'm trying to get ID and Desciption values from the selected row in a grid when clicking on it, but i cant get it to work. The RadGrid_SelectedIndexChanged event is trigged but SelectedItems is always empty. Any suggestion whats wrong?

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="SpamControlRadScriptManager" runat="server"/>
    <div>
        <telerik:RadGrid runat="server" ID="RadGrid" OnSelectedIndexChanged="RadGrid_SelectedIndexChanged" AutoGenerateColumns="false" Width="300">
            <MasterTableView DataKeyNames="ID">
                <Columns>
                    <telerik:GridNumericColumn DataField="ID" UniqueName="IDGridNumericColumn" />
                    <telerik:GridBoundColumn DataField="Description" UniqueName="OverviewLanguagGridBoundColumn" />
                </Columns>
            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
    </form>
</body>
</html>

Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable myDataTable = new DataTable();
        DataColumn myDataColumn;

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.String");
        myDataColumn.ColumnName = "ID";
        myDataTable.Columns.Add(myDataColumn);

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.String");
        myDataColumn.ColumnName = "Description";
        myDataTable.Columns.Add(myDataColumn);

        DataRow row;
        row = myDataTable.NewRow();
        row["ID"] = "1";
        row["Description"] = "Test1";
        myDataTable.Rows.Add(row);

        row = myDataTable.NewRow();
        row["ID"] = "2";
        row["Description"] = "Test2";
        myDataTable.Rows.Add(row);

        RadGrid.DataSource = myDataTable;
        RadGrid.DataBind();
    }

    protected void RadGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        // This is always 0
        int count = RadGrid.SelectedItems.Count;

        if (count > 0)
        {
            var dataItem = RadGrid.SelectedItems[0] as GridDataItem;
            if (dataItem != null)
            {
                var ID = dataItem["ID"].Text;
                var desc = dataItem["Description"].Text;
            }
        }
    }
}

Thanks!
Rickard
Michael
Top achievements
Rank 1
 answered on 07 Dec 2012
0 answers
49 views
Hello,
I have a Usercontrol with a RadComboBox that gets items via a webservice.
Everything is working correctly, however when I type, the search text disappears.
I had the same exact behavior with postbacks, but now its not posting back, and it is still doing the same thing.

Please take a look at the code below.
Here is the code for the RadComboBox:
<telerik:RadComboBox
    ID="cboContentProvider"
    runat="server"
    Width="225px"
    CheckBoxes="true"
    EmptyMessage="-- Select --"
    EnableLoadOnDemand="True"
    ShowMoreResultsBox="True"
    OnClientItemChecked="ItemChecked"
    EnableVirtualScrolling="True">
    <WebServiceSettings Method="GetContentProviderData" Path="../../WebService/BoomboxWs.asmx" />
    <ExpandAnimation Type="InOutElastic" />
</telerik:RadComboBox>

Here is the code for CP_ItemChecked:
function CP_ItemChecked(sender, eventArgs) {
    var data = '{ "type": "' + sender.get_id() + '", "id": "' + eventArgs.get_item().get_value() + '" }';
    $.ajax({
        type: "POST",
        url: "../../WebService/BoomboxWs.asmx/MarkSelectedItem",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
        }
    });
}

Here is the WebMethod:
[WebMethod(EnableSession = true)]
public RadComboBoxData GetContentProviderData(RadComboBoxContext context)
{
    return GetRadComboBoxData(context, DtCp, DtCp.Count());
}
 
public RadComboBoxData GetRadComboBoxData(RadComboBoxContext context, List<GenericDataList> data, int itemsPerRequest = 20)
{
    var comboData = new RadComboBoxData();
 
    var itemOffset = context.NumberOfItems;
    var endOffset = itemOffset + itemsPerRequest;
 
    if (endOffset > data.Count())
    {
        endOffset = data.Count();
    }
 
    if (!string.IsNullOrEmpty(context.Text))
    {
        data = data.Where(q => q.Name.ToUpper().Contains(context.Text.ToUpper())).ToList();
    }
 
    comboData.EndOfItems = endOffset == data.Count();
 
    var result = new List<RadComboBoxItemData>(endOffset - itemOffset);
 
    result.AddRange(data.Take(endOffset).Skip(itemOffset)
        .Select(radItem => new RadComboBoxItemData {Text = radItem.Name, Value = radItem.Id.ToString(CultureInfo.InvariantCulture)}));
 
    comboData.Message = data.Any() ? String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, data.Count()) : "No matches";
    comboData.Items = result.ToArray();
 
    return comboData;
}
Edward
Top achievements
Rank 1
 asked on 07 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?