Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
148 views
When I was using a GridClientSelectColumn to select rows in my RadGrid, I used this post and this post to persist the checked state on the client side, using JavaScript to store the selected row ids in a hidden field.

I'd like to do this with checkboxes that are GridTemplateColumns defined on the server side, like this:

    foreach (blah blah)
    {
        templateColumn = new GridTemplateColumn();
        RadGrid1.MasterTableView.Columns.Add(templateColumn);
        templateColumn.ItemTemplate = new MyTemplate(blah);
        templateColumn.HeaderText = blah;
    }
 
private class MyTemplate : ITemplate
{
    protected CheckBox chk;
    private string columnName;
 
    public MyTemplate(string columnName)
    {
        this.columnName = columnName;
    }
 
    public void InstantiateIn(Control container)
    {
        chk = new CheckBox();
        chk.ID = "chk" + columnName;
        chk.DataBinding += new EventHandler(DataBinding);
        chk.Enabled = true;
        container.Controls.Add(chk);
    }
 
    void DataBinding(object sender, EventArgs e)
    {
        CheckBox cBox = (CheckBox)sender;
        GridDataItem container = (GridDataItem)cBox.NamingContainer;
        cBox.Checked = (bool)((DataRowView)container.DataItem)[columnName];
    }
}

I think I can do the same kind of thing here, except I can no longer call the JavaScript function RadGrid1_RowSelected since I'm not selecting the row, just checking boxes. I'll need to use another event that fires when a checkbox is checked or unchecked (I guess that's CheckChanged). But how do I add a handler on the server side and have it handled on the client side?
Kostadin
Telerik team
 answered on 19 Sep 2013
1 answer
145 views
Hi, i am trying to make a confirmation box when moving an appointment.
The problem here is that the:
args.get_targetSlot().get_startTime().format("HH:mm");

returns wrong time, wye is that?

function onAppointmentMoveEnd(sender, args) {
           
           var appointment = args.get_appointment();
           var scheduler = $find("<%= RadScheduler1.ClientID %>");
 
           var fromTime = appointment.get_start();
 
           var customerName = appointment.get_resources().getResourceByType("Kunder").get_text();
           var fromRoom = appointment.get_resources().getResourceByType("Rum").get_text();
 
           var targetRoom = args.get_targetSlot().get_resource().get_text();
 
           var targetTime = args.get_targetSlot().get_startTime().format("HH:mm");
 
           // Calculate the duration of the appointment
           var appointmentDuration = appointment.get_end() - appointment.get_start();
 
           var newFromEndTime = new Date(fromTime.getTime() + appointmentDuration);
           var editSeries = args.get_editingRecurringSeries();
            
           // Pop a confirmation window
           var confirmMessage = "Är du säker pÃ¥ att du vill flytta " + customerName + "?<p> <strong> FrÃ¥n:</strong> " + fromRoom + " <strong>kl:</strong> " + fromTime.format("HH:mm") + "<br/> <strong>Till:</strong> " + targetRoom + " <strong>kl:</strong> " + targetTime + "</p>";
 
           radconfirm(confirmMessage,
           function (arg) {
               if (arg == false) {
                   // The user has confirmed moving the appointment. Update the start and end time.
                   appointment.set_start(fromTime);
                   appointment.set_end(newFromEndTime);
                   scheduler.updateAppointment(appointment, editSeries);
               }
           }, 330, 100);
       }
Plamen
Telerik team
 answered on 19 Sep 2013
4 answers
131 views
Hi,

We are using the telerik (latest library) Grid with "Outlook" skin , problem is when grid rows gets selected header and selected row color appear same (blue).
if there a way to change the selected row color ? also we have a requirement to use only "outlook" skin.
Please suggest me to rid this issue.
Afroz khan
Top achievements
Rank 1
 answered on 19 Sep 2013
1 answer
155 views
Hi,

Thanks in advance for some help.  Here's our situation:

  1. We have a RadAutocompleteBox
  2. Inside a RadPanelBar item Content Template.
  3. Sitting in a RadSlidingPane
  4. When RadAutoCompleteBox's dropdown should be visible, it is not.

We assume that this is a problem with the z-index of the listRac element, but we have not had luck manipulating that element via CSS. Other than not being able to see the drop down list, the RAC seems to work fine.  Screenshot attached.

Any ideas?

Thanks,

Jim
Princy
Top achievements
Rank 2
 answered on 19 Sep 2013
1 answer
96 views
This is not a telerik specific query. When I select the text by double clicking or click and dragging, How can I get the selected text in js? 

Thankyou
Robert
Shinu
Top achievements
Rank 2
 answered on 19 Sep 2013
1 answer
427 views
I am trying to use the insert button to insert a record into my datatable, i have the following code that i tried, but when i click on the insert button nothing happens, it just seems to refresh the page, can someone please help me out:

ususing System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.ComponentModel;
 
public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["GridData"] == null)
        {
            DataTable table = GetTable();
            Session.Add("GridData", table);
        }
        DefineGridStructure();
    }
 
 
    private void DefineGridStructure()
    {
        RadGrid grid = new RadGrid();
        grid.ID = "RadGrid1";
        grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource);
        grid.AutoGenerateEditColumn = true;
        grid.AutoGenerateDeleteColumn = true;
        grid.AllowAutomaticInserts = true;
        grid.Width = Unit.Percentage(100);
        grid.PageSize = 15;
        grid.AllowPaging = true;
        grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
        grid.AutoGenerateColumns = false;
        grid.MasterTableView.Width = Unit.Percentage(100);
        grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
        grid.ItemInserted += grid_ItemInserted;
         
        grid.MasterTableView.DataKeyNames = new string[] { "RowNumber" };
        GridBoundColumn boundColumn = new GridBoundColumn();
        boundColumn.DataField = "RowNumber";
        boundColumn.HeaderText = "RowNumber";
        boundColumn.ReadOnly = true;
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Size";
        boundColumn.HeaderText = "Size";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Description";
        boundColumn.HeaderText = "Description";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Quantity";
        boundColumn.HeaderText = "Quantity";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Duration";
        boundColumn.HeaderText = "Duration";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "DurationType";
        boundColumn.HeaderText = "DurationType";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Amount";
        boundColumn.HeaderText = "Amount";
        grid.MasterTableView.Columns.Add(boundColumn);
        PlaceHolder1.Controls.Add(grid);
    }
 
    private void grid_ItemInserted(object sender, GridInsertedEventArgs e)
    {
        RadGrid grid = (RadGrid)sender;
        int rowIndex = 0;
        if (Session["GridData"] != null)
        {
            DataTable dtCurrentTable = (DataTable)Session["GridData"];
            DataRow drCurrentRow = null;
 
            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
                {
 
                    GridEditFormInsertItem item = e.Item as GridEditFormInsertItem;
                    TextBox box1 = item.FindControl("Size") as TextBox;
                    TextBox box2 = item.FindControl("Description") as TextBox;
                    TextBox box3 = item.FindControl("Quantity") as TextBox;
                    TextBox box4 = item.FindControl("Unit") as TextBox;
                    TextBox box5 = item.FindControl("Duration") as TextBox;
                    TextBox box6 = item.FindControl("DurationType") as TextBox;
                    TextBox box7 = item.FindControl("Amount") as TextBox;
 
                    drCurrentRow = dtCurrentTable.NewRow();
                    drCurrentRow["RowNumber"] = i + 1;
                    dtCurrentTable.Rows[i - 1]["Size"] = box1.Text;
                    dtCurrentTable.Rows[i - 1]["Description"] = box2.Text;
                    dtCurrentTable.Rows[i - 1]["Quantity"] = box3.Text;
                    dtCurrentTable.Rows[i - 1]["Unit"] = box4.Text;
                    dtCurrentTable.Rows[i - 1]["Duration"] = box5.Text;
                    dtCurrentTable.Rows[i - 1]["DurationType"] = box6.Text;
                    dtCurrentTable.Rows[i - 1]["Amount"] = box7.Text;
                    rowIndex++;
 
                }
                dtCurrentTable.Rows.Add(drCurrentRow);
                Session["GridData"] = dtCurrentTable;
                grid.DataSource = Session["GridData"];
                grid.Rebind();
            }
        }
    }
 
 
 
    void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable current = (DataTable)Session["GridData"];
        RadGrid grid = (RadGrid)sender;
        grid.DataSource = current;
    }
 
 
 
    static DataTable GetTable()
    {
        //
        // Here we create a DataTable with a few columns.
        //
        // Create Datatable to store all colums
        DataTable dt = new DataTable();
        DataRow dr = null;
        dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
        dt.Columns.Add(new DataColumn("Size", typeof(string)));
        dt.Columns.Add(new DataColumn("Description", typeof(string)));
        dt.Columns.Add(new DataColumn("Quantity", typeof(string)));
        dt.Columns.Add(new DataColumn("Unit", typeof(string)));
        dt.Columns.Add(new DataColumn("Duration", typeof(string)));
        dt.Columns.Add(new DataColumn("DurationType", typeof(string)));
        dt.Columns.Add(new DataColumn("Amount", typeof(string)));
        dr = dt.NewRow();
        dr["RowNumber"] = 1;
        dr["Size"] = string.Empty;
        dr["Description"] = string.Empty;
        dr["Quantity"] = string.Empty;
        dr["Unit"] = string.Empty;
        dr["Duration"] = string.Empty;
        dr["DurationType"] = string.Empty;
        dr["Amount"] = string.Empty;
        dt.Rows.Add(dr);
        return dt;
    }
 
}
Eyup
Telerik team
 answered on 19 Sep 2013
5 answers
269 views
Hi,
How can I get the masked text from a RadNumericTextBox?
For example...

// RadTextBox
RadNumericTextBox rntb = new RadNumericTextBox();
rntb.NumberFormat.PositivePattern = "n%";
rntb.NumberFormat.DecimalDigits = 0;
rntb.MinValue = 0;
rntb.MaxValue = 100;
rntb.Text = 50; // Displays as "50%"
 
// How do I get "50%" into a label?
Label lbl = new Label();
lbl.Text = rntb.Text; // Only shows "50". I want to show "50%"

In the above example, how can I get the masked value "50%"?
TextWithLiterals would be great but only applies to RadMaskedTextBox. 

Thanks!
Joe
Top achievements
Rank 2
 answered on 19 Sep 2013
1 answer
200 views
Here is the link I posted on the asp.net: 

http://forums.asp.net/t/1935517.aspx?Load+userControl+first+time+get+called+and+load+properly+Page_Load+then+click+on+the+Sorting+or+pageSize+changed+on+the+RadGrid+that+control+did+not+load

Here is my iTemplate class: 
        public class iTemplate : ITemplate
        {
            private string columnName;
            Page page; 

            public iTemplate(string cName, Page page)
            {
                columnName = cName;
                this.page =page; 
            }

            public void InstantiateIn(System.Web.UI.Control container)
            {
                Control ctrl = new Control();
                
                //System.Web.UI.
                
                //MWStringCrtl mwstringCtrl = (MWStringCrtl)loadMwstringCtrl();
                MWStringCrtl mwstringCtrl = (MWStringCrtl)page.LoadControl("~/ServiceModules/Controls/MWStringCrtl.ascx");
                mwstringCtrl.Wrapper = new MWStringCrtl.DataWrapper();
                mwstringCtrl.ID =container.ClientID+ "_mctrl";
                mwstringCtrl.DataBinding += new EventHandler(this.BindData);
                mwstringCtrl.Wrapper.ValueOnNewLine = false;
                mwstringCtrl.Wrapper.ValueFontSize = 12;
                SimpleStringDto blankCell = new SimpleStringDto();
                blankCell.Text = "hello";

                mwstringCtrl.Wrapper.Data = blankCell; 
                container.Controls.Add(mwstringCtrl);
            }


            public void BindData(object sender, EventArgs e)
            {
                MWStringCrtl mc = (MWStringCrtl)sender;
                GridDataItem container = (GridDataItem)mc.NamingContainer;
                mc.Wrapper = (MWStringCrtl.DataWrapper)((RowDataWrapper)container.DataItem).GetType().GetProperty(columnName).GetValue((RowDataWrapper)container.DataItem, null);
            }
        }

when load the Grid first time, first instantiateIn the User control and bind the data, and lastly Page_Load the dynamically user control. 

However, when Sorting or paging, first Instantiateln the User control and Page_Load the dynamically User Control, and last Bind the Data, which in result will have the empty Grid. 

anybody can help, it is urgent? 

Thanks,T
Eyup
Telerik team
 answered on 19 Sep 2013
7 answers
129 views
Duplicate insert problem.

I insert an item and after the insert successfully happens I call:

RadGridOperators.MasterTableView.IsItemInserted = false;
e.Canceled = true;
RadGridOperators.MasterTableView.ClearEditItems();
RadGridOperators.MasterTableView.Rebind();

The edit form does in deed close but if I hit the refresh button on the web browser the insert happens again (EVEN THOUGH THE EDIT FORM IS NOT OPEN). How can I avoid this behavior??
Eyup
Telerik team
 answered on 19 Sep 2013
2 answers
107 views
Hi,
i am using rad window to show errors or success but i want
1] only close and pin button
2] Dont want scrolling
2] Dont want last Section(splitted part) of window

My code and screenshot is
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
    </telerik:RadWindowManager>
    <telerik:RadWindow ID="radwindowPopup" runat="server" Animation="FlyIn" CssClass="modalPopup"
        DestroyOnClose="true" EnableShadow="true" IconUrl="~/Images/Bi.ico" KeepInScreenBounds="true"
        Width="420px" Height="150px" MaxHeight="150px" MaxWidth="420px" MinHeight="150px"
        MinWidth="420px" Modal="true" RenderMode="Classic" VisibleStatusbar="true" VisibleTitlebar="true"
        Behaviors="Close" Title="Manifest-BI" Skin="Web20">
        <ContentTemplate>
            <center>
                <div style="padding: 20px">
                    Are you sure you want to Delete this Record?
                    <br />
                    <br />
                    <telerik:RadButton ID="btnOk" runat="server" Text="Yes" Width="70px" OnClick="btnOk_Click"
                        Skin="Web20" />
                        
                    <telerik:RadButton ID="btnCancel" runat="server" Text="No" Width="70px" OnClick="btnCancel_Click"
                        Skin="Web20" />
                </div>
            </center>
        </ContentTemplate>
    </telerik:RadWindow>
and

Swapnil
Top achievements
Rank 1
 answered on 19 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?