Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
91 views

I have some Numeric Textboxes where I am using the OnValueChanging client event to do some validation and when I utilize the eventArgs.set_cancel(true) function, the value is reverted back to the old value, however the currency format is lost when I exit the field. If I reenter the field and exit again, the dollar sign will display properly.

 

Here is a sample of the script: 

function onValueChanging(sender, eventArgs) {
    var value = eventArgs.get_newValue();
 
    var txtTest = $find("<%= txtTest.ClientID %>");
 
    if ((value < sender.get_minValue()) || (value > txtTest.get_value())) {
        alert('Value must be a non-negative number and cannot exceed txtTest');
        eventArgs.set_cancel(true);
    }
}

Konstantin Dikov
Telerik team
 answered on 10 Jun 2015
1 answer
231 views

Hi,

We have a radgrid.We have a requirement like entering the time and finding the sum of all the cells and display into the last column  of the grid when columns are generating dynamically.

We have tried with client side event on row selected event but sum is not coming when moving from one cell to second cell.

Below i am giving the scenarios how we have used the client events please reply to this thread as early as possible.

 



 

1.       We are
able to fetch the selected cell value but unable to fetch the remaining
corresponding cell values. You can find the same in the sample project
(BatchEdit.aspx – OnBatchEditCellValueChanged event)
source code:
 <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
      <script type="text/javascript">
          function BatchEditCellValueChanged(sender, args) {


              var grid = sender;

              var row = args.get_row();
              var cell = args.get_cell();
              var tableView = args.get_tableView();
              var column = args.get_column();
              var columnUniqueName = args.get_columnUniqueName();
              var editorValue = args.get_editorValue();
              var cellValue = args.get_cellValue();
              alert(editorValue);

              var columnlength = grid.get_masterTableView().get_columns().length;
              for (i = 0 ; i < columnlength; i++) {
                  cell = grid.get_masterTableView().get_columns()[i].get_uniqueName();
                  alert(cell);
              }

          }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
       <div>
     <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView EditMode="Batch" BatchEditingSettings-EditType="Cell">
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="True" CellSelectionMode="MultiCell" />
            <ClientEvents OnBatchEditCellValueChanged="BatchEditCellValueChanged" />
        </ClientSettings>
    </telerik:RadGrid>
    </div>
    </form>
</body>
</html>

 code Behind:
public partial class BatchEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GetValues();
    }
    private void GetValues()
    {
        DataTable dtTable = new DataTable();
        dtTable.Columns.Add("Sum");
        dtTable.Columns.Add("Value1"); dtTable.Columns.Add("Value2");
        dtTable.Columns.Add("Value3"); dtTable.Columns.Add("Value4");

        DataRow dr = dtTable.NewRow();
        dr["Sum"] = "";
        dr["Value1"] = "1"; dr["Value2"] = "2";
        dr["Value3"] = "3"; dr["Value4"] = "4";
        dtTable.Rows.Add(dr);

        DataRow drr = dtTable.NewRow();
        drr["Sum"] = "";
        drr["Value1"] = "5"; drr["Value2"] = "6";
        drr["Value3"] = "7"; drr["Value4"] = "8";
        dtTable.Rows.Add(drr);


        RadGrid1.DataSource = dtTable;
        RadGrid1.DataBind();

    }
}
2.       We are
able to fetch the selected cell value and corresponding cell values in the same
row by hardcoding the column names, but dynamically we are unable to get the
values of the cell. You can find the same in the sample project
(OnRowSelected.aspx – OnRowSelected event)
source code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnRowSelected.aspx.cs" Inherits="OnRowSelected" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

  <script type="text/javascript">
      function RowSelected(sender, eventArgs) {
          var grid = sender;
          var MasterTable = grid.get_masterTableView();
         
          var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
          var cell1 = MasterTable.getCellByColumnUniqueName(row, "Value1");
          var cell2 = MasterTable.getCellByColumnUniqueName(row, "Value2");
          var cell3 = MasterTable.getCellByColumnUniqueName(row, "Value3");
          var cell4 = MasterTable.getCellByColumnUniqueName(row, "Value4");
          var total = 0;
          var arr = [];
          var total = 0;
      
          var columnlength = grid.get_masterTableView().get_columns().length;
          for (i = 0 ; i < columnlength; i++) {
              cell = grid.get_masterTableView().get_columns()[i].get_uniqueName();
           
              var cell = MasterTable.getCellByColumnUniqueName(row, cell);
              var val = parseInt(cell.innerText);
              arr[i] = val;
             

          }
          for (i = 1; i < arr.length; i++) {

              total += arr[i];
          }

          var cell1 = MasterTable.getCellByColumnUniqueName(row, "Sum");
          cell1.innerText = total;
          cell1.eventArgs.set_cancel(true);


      }
    </script>
   <%-- var grid = $find("<%=RadGrid1.ClientID%>");
    var tableView = sender.get_masterTableView();
    var batchManager = sender.get_batchEditingManager();
    var items = tableView.get_dataItems();
    var mapValues = [];
    for (var i = 0; i < items.length; i++) {
        var mapCell = items[i].get_cell("Map");
        var mapValue = batchManager.getCellValue(mapCell);
        mapValues.push(mapValue);
    }--%>
</head>
<body>
    <form id="form1" runat="server">
         <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
         <asp:HiddenField ID="HiddenField1" runat="server" />
    <div>
    <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView EditMode="Batch" BatchEditingSettings-EditType="Cell" >
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="True" CellSelectionMode="MultiCell" />
            <ClientEvents OnRowClick="RowSelected" />
        </ClientSettings>
    </telerik:RadGrid>
    </div>
    </form>
</body>
</html>

code behind:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OnRowSelected : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GetValues();
    }
    private void GetValues()
    {
        DataTable dtTable = new DataTable();
        dtTable.Columns.Add("Sum");
        dtTable.Columns.Add("Value1"); dtTable.Columns.Add("Value2");
        dtTable.Columns.Add("Value3"); dtTable.Columns.Add("Value4");

        DataRow dr = dtTable.NewRow();
        dr["Sum"] = "";
        dr["Value1"] = "1"; dr["Value2"] = "2";
        dr["Value3"] = "3"; dr["Value4"] = "4";
        dtTable.Rows.Add(dr);

        DataRow drr = dtTable.NewRow();
        drr["Sum"] = "";
        drr["Value1"] = "5"; drr["Value2"] = "6";
        drr["Value3"] = "7"; drr["Value4"] = "8";
        dtTable.Rows.Add(drr);


        RadGrid1.DataSource = dtTable;
        RadGrid1.DataBind();

    }
}
 

Angel Petrov
Telerik team
 answered on 10 Jun 2015
16 answers
1.1K+ views
Hi,

I have a webservice where i am creating the RadGrid Object dynamically. I have assigned the Dataview object as the datasource to this Grid. And now my requirement is to export this data directly to the filename which i mention in the code and it should be saved automatically i.e. i should not get the Save popup. I have tried the following code but it is not working faling in ExportToExcel saying "RadGrid must be databound before exporting telerik". Please let me know whether i would be able to save it directly to the file without rendering the grid control on the page as i have to do this in webservice method, no page is present. And why am getting the above mentioned error.

                RadGrid grid = new RadGrid(); 
                grid.ID = "radgridExportToExcel"
                grid.HeaderStyle.Font.Bold = true
                grid.DataSource = dsFileListToDelete.Tables[0].DefaultView; 
                string currentdatetime = DateTime.Now.ToString(); 
                string metadataReportName = string.Format(@"{0}\{1}_Metadata", Server.MapPath(@"~/WCCMetadataReports"), currentdatetime.Replace(" """).Replace("/""").Replace(":""")); 
                // render the DataGrid control to a file 
                grid.ExportSettings.ExportOnlyData = true
                grid.ExportSettings.IgnorePaging = true
                grid.ExportSettings.OpenInNewWindow = false
                grid.ExportSettings.FileName = metadataReportName; 
                grid.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML; 
                grid.Rebind(); 
                grid.MasterTableView.ExportToExcel(); 

Kostadin
Telerik team
 answered on 10 Jun 2015
2 answers
132 views

Hi there,

 Is there a way to customize the node inspector module of Rad Editor?  I need to remove the functionality for CLASSNAME and PROPERTIES button.  So all that would be available is width, height, border color/width, tooltip, title, and alignment?  

Marin Bratanov
Telerik team
 answered on 10 Jun 2015
3 answers
129 views

Hi, i have a problem, i see demo http://demos.telerik.com/aspnet-ajax/dock/examples/dockresize/defaultcs.aspx where i see drag and resize dock panel, but i want use code like this

<telerik:RadDockLayout ID="RadDockLayout1" runat="server">
                    <telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="300" Width="300">
                            <telerik:RadDock ID="RadDock1" runat="server" Title="RadDock1" Width="200px" Resizable="true" EnableDrag="True"
                                Text="RadDock is placed in a <strong>vertically</strong> oriented RadDockZone. Grab the bottom handle to resize the dock vertically. Horizontal resizing is not allowed." CssClass="higherZIndex">
                            </telerik:RadDock>
                        <telerik:RadDock ID="RadDock2" runat="server" Title="RadDock1" Width="200px" Resizable="true" EnableDrag="True"
                                Text="RadDock is placed in a <strong>vertically</strong> oriented RadDockZone. Grab the bottom handle to resize the dock vertically. Horizontal resizing is not allowed." CssClass="higherZIndex">
                            </telerik:RadDock>
                    </telerik:RadDockZone>
                    </telerik:RadDockLayout>

 

where user must be have ability for resize docks but can't drag, now user can't resize. What am i doing wrong?

Slav
Telerik team
 answered on 10 Jun 2015
1 answer
46 views

Hi,

please any one help me code or demo for Hierarchy grid parent with one child and child only have edit column

Eyup
Telerik team
 answered on 10 Jun 2015
5 answers
45 views

Hello,

 When hitting a new line on Mozilla or Chrome, it introduces a <br/> tag, which is fine for us. However in IE the editor wraps up the line inside <p>...</p> tags, thus introducing a double spacing. Is there any way to put IE in line with the other browsers?

Regards

Ianko
Telerik team
 answered on 10 Jun 2015
1 answer
819 views
How to replace UpdatePanel with telerik, what to use RadAjaxManager or RadAjaxPanel. The UpdatePanel contains ListBox control where the items are retrieved from the database. Is there any replacement for ContentTemplate in telerik too?

<td class="td_populate">
<asp:UpdatePanel ID="updp1" runat="server">
<ContentTemplate>                                       
<asp:ListBox ID="countryCode" runat="server" Rows="1"></asp:ListBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="countryCode"
Display="Dynamic" ErrorMessage="* Please select the Country Code" SetFocusOnError="True" />
</ContentTemplate>
</asp:UpdatePanel>
</td>

<td class="td_populate">
<asp:UpdatePanel ID="updp2" runat="server">
<ContentTemplate>
<asp:ListBox ID="region" runat="server" Rows="1">
<asp:ListItem Value="">--- SELECT ---</asp:ListItem>
</asp:ListBox>                            
<asp:RequiredFieldValidator ID="RFV2" runat="server" ControlToValidate="region"
Display="Dynamic" ErrorMessage="* Please select the region code" SetFocusOnError="True" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="region" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>

How to migrate this controls using telerik?
Marin Bratanov
Telerik team
 answered on 10 Jun 2015
3 answers
107 views

Hello,

 I'm experiencing a strange behavior. I'm using in the same page a RadGrid with EditMode="Batch" and other RadInputs with SelectionOnFocus="SelectAll".

The problems is:

The focus on the inputs don't always select the content as they should. It only happens when the EditMode of the grid is "Batch". When I remove the property the focus works fine.

 

Is there any workaround? Am I missing some property that handles that?

 

This is an example of one of the textboxes:

<telerik:RadTextBox
    ID="txtInputText" runat="server" Width="100%" ShowButton="False" TextMode="SingleLine"
    Rows="1" ReadOnly="False" Enabled="True" onkeydown="ignorarEnter(this,event)"
    OnTextChanged="txtInputText_OnTextChanged" SelectionOnFocus="SelectAll" />

And here is my RagGrid:

<telerik:RadGrid
    Width="100%" Height="100%" Style="border: 0; outline: none" CssClass="gridClass"
    runat="server" ID="grdControl" ClientIDMode="Predictable" BorderWidth="0px"
    OnItemCommand="grdControl_ItemCommand" OnNeedDataSource="grdControl_NeedDataSource"
    OnBatchEditCommand="grdControl_BatchEditCommand" PageSize="50"
    AllowSorting="true" Culture="pt-BR" AutoGenerateColumns="false"
    AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
    AllowAutomaticDeletes="true" FilterType="Classic"
    AllowPaging="false" AllowFilteringByColumn="false">
    <MasterTableView
        TableLayout="Fixed" AllowPaging="false" AllowFilteringByColumn="false"
        Width="100%" CommandItemDisplay="None" >
        <BatchEditingSettings SaveAllHierarchyLevels="true" EditType="Row" OpenEditingEvent="DblClick" />
        <RowIndicatorColumn Visible="False" />
        <ExpandCollapseColumn Created="True" />
        <Columns>
            <telerik:GridBoundColumn UniqueName="text1" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number1" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date1" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool1" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text2" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number2" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date2" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool2" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text3" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number3" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date3" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool3" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text4" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number4" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date4" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool4" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text5" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number5" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date5" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool5" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text6" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number6" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date6" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool6" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text7" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number7" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date7" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool7" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text8" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number8" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date8" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool8" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text9" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number9" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date9" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool9" Visible="false" />
            <telerik:GridBoundColumn UniqueName="text10" Visible="false" />
            <telerik:GridNumericColumn UniqueName="number10" Visible="false" />
            <telerik:GridDateTimeColumn UniqueName="date10" Visible="false" />
            <telerik:GridCheckBoxColumn UniqueName="bool10" Visible="false" />
        </Columns>
    </MasterTableView>
    <PagerStyle
        AlwaysVisible="false" PageSizeControlType="None" CssClass="grdpager" Position="Bottom" />
    <HeaderContextMenu RenderMode="Lightweight" />
 
    <ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true">
 
        <ClientEvents OnKeyPress="desbilitarEnterGrid" />
 
        <Selecting AllowRowSelect="true" />
        <Resizing
            AllowRowResize="false" AllowColumnResize="true" AllowResizeToFit="true"
            ClipCellContentOnResize="true" EnableRealTimeResize="false"
            ResizeGridOnColumnResize="false" />
        <Scrolling AllowScroll="true" UseStaticHeaders="True" />
    </ClientSettings>
 
</telerik:RadGrid>

 

Konstantin Dikov
Telerik team
 answered on 10 Jun 2015
3 answers
133 views

I created my own CompositeControl that extends and automates many tasks for me with the RADGrid. Posting the code in it's entirety is impossible because of how complex it is. But I am going to do my best to explain the gist of my problem and what I am  looking for.

I use the RADGrid almost entirely using Server-Side code (VB.Net flavor). Now ad the time I initialize my grid (at page load) I add a custom Template to the MasterTableView.NestedViewTemplate. The custom template is a class I created inheriting from ITemplate and implements the InstantiateIn method. I set the MasterTableView.HierarchyLoadMode = Client as well. The template I created simply displays additional fields on the same parent record (ie: row) that I manually have hidden from the RADGrid column list (for lack of space). If the user wants to see the additional information, expanding the nested view will show them the remaining fields.

The first time my page/grid load...works perfectly, the arrow appears on the left side of each record and if clicks it expands to show my custom NestedViewTemplate. However the problem I have is that I am also sometimes allowing for paging, and if the user changes the page I lose the NestedViewTemplate completely. The arrows to the left of each row vanish.

I have saved the ITemplate class into the ViewState so that I can "reattach" it if it is found to be missing at a later reload. I have looked all around to see at which point I need to reattach it, but no matter where I re-attach the NestedViewTemplate, it doesn't re-appear on a page index change.

My question is, at which event should I be re-attaching the NestedViewTemplate so that it is early enough in the event timeline that it can bind with the parent data and display on the RADGrid? I've tried Page_Init, Page_Load, and grid_DataBinding...no luck. When stepping through my code, I see that at the time that the PageIndex is changed, the NestedViewTemplate is loaded into the RADGrid. The only thing I noticed that is different is that in the initial load of the grid, the gridDataBinding() event is fired, but when the page index is changed it does not fire.

HELP!

Kostadin
Telerik team
 answered on 10 Jun 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?