Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
475 views

We have a rad grid.We are binding the grid using datatable and auto generated columns are true.

We want to add all the cell values and display the sum of all the cell values in other column when cell click.

we have tried with row selected event but the sum is not displaying properly when moving from one cell to other.

Please help us to fix the issue.

 

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)

 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)

we have used the following code

<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>

and code behind is

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();

    }
}

Any other information please contact us.

Viktor Tachev
Telerik team
 answered on 20 Aug 2015
7 answers
1.1K+ views
I have the following RadListBox:
     <telerik:RadListBox ID="AttachmentsRadListBox"  CheckBoxes ="true" runat="server" />
it is located in a RadWindow, therefore I am populating it through the following code which is only called when RadWidnow becomes visible:


                AttachmentsRadListBox.DataSource = AttachDT
                AttachmentsRadListBox.DataTextField = "DocumentPath"
                AttachmentsRadListBox.DataValueField = "DocumentID"
                AttachmentsRadListBox.DataBind()
                For Each item As RadListBoxItem In AttachmentsRadListBox.Items
                    item.Checked = True
                Next
So far so good, the RadListBox is populated and all the items are checked.

Now, there is a Save button on the RadWindow when pressed before closing the window I am trying to read the checked items in the AttachmentsRadListBox (Since the user might have changed the status of the checked items). But every effort on reading the items has failed, for example on the Save button click I have the following: 

        Dim test As Integer = AttachmentsRadListBox.Items.Count  // THIS IS ZERO
        For Each item As RadListBoxItem In AttachmentsRadListBox.Items  // THERE ARE NO ITEMS
            If Not item.Checked Then
                Dim DocumentIDToDelete As Integer = item.Value
            End If
        Next
Why is that the last piece of code does not behave as I hope? The AttachmentsRadListBox is not being bounded again through the postback. The only time that it is bounded is when the RadWindow appears. Then the Save button on the RadWindow obviously creates a postback but I don't understand why AttachmentsRadListBox contains no item at that point.


Thomas
Top achievements
Rank 1
 answered on 20 Aug 2015
1 answer
200 views

Hi

Is there a equivalent to the $(document).on function for the clientSelectedIndexChanging and clientSelectedIndexChanged events for a RadCombobox in jQuery?

Viktor Tachev
Telerik team
 answered on 20 Aug 2015
1 answer
45 views

Hi,

I have radgrid with the possibility of adding a line.
One column is of GridDropDownColumn.
How to play the DropDown ??

Thank you.​

Viktor Tachev
Telerik team
 answered on 20 Aug 2015
1 answer
370 views

We recently updated to the newest version 2015.2.729.40 and our Rotator image onclick doesn't work in Chrome and doesn't work on some machines in IE.

 We had <asp:Image controls in our rotator which are rendered as <mg

 To correct this, we had to change the control type to <asp:ImageButton which renders as <input

  Again, this issue only happened after our recent updated to version 2015.2.729.40

 Simplified example below

<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default1.aspx.vb" Inherits="TestWebRoot._Default" %>
 
<!DOCTYPE html>
 
<html>
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
 
        <telerik:RadRotator ID="RadRotator1" runat="server" Height="300px" Width="823px" BackColor="White"
            ScrollDuration="5000" FrameDuration="10000" ItemHeight="300px" ItemWidth="823px" PauseOnMouseOver="true"
            RotatorType="SlideShow" ScrollDirection="Left" BorderWidth="0px" SlideShowAnimation-Type="CrossFade"
            WrapFrames="False">
            <Items>
                <telerik:RadRotatorItem>
                    <ItemTemplate>
                        <table style="position: relative;">
                            <tr>
                                <td style="vertical-align: top;">
                                    <div class="Center ProductLabel" style="width: 100%; height: 20px;">
                                        img control
                                    </div>
                                    <img id="Img2" runat="server" src="~/images/logo.jpg" style="width: 50px; height: 50px;" alt="My Image" onclick="alert('here'); return false;" title="MyTitle" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="Center ProductLabel" style="width: 100%; height: 20px;">
                                        ImageButton
                                    </div>
                                    <asp:ImageButton ID="Image1" runat="server" style="width: 50px; height: 50px;" AlternateText="My Image" ImageUrl="~/images/logo.jpg" OnClientClick="alert('here'); return false;" />
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </telerik:RadRotatorItem>
            </Items>
        </telerik:RadRotator>
        Test Image outside Rotator
        <img id="Img1" runat="server" class="Link" src="~/images/logo.jpg" onclick="alert('here');" />
    </form>
</body>
</html>

Slav
Telerik team
 answered on 20 Aug 2015
1 answer
174 views

I am having a strange problem. First let me start by saying that I am using the Telerik controls supplied by DotNetNuke. So I can not "upgrade" to any other version of the Telerik controls. I am stuck with what I am given.

I wrote a module initially using Telerik v2012.2.724.35 (which was bundled with DNN v6.02.09)and it worked great. I unfortunately am forced to upgrade to a new DNN version because of a bog in Telericks RADSchedule (which effect the month of November only). So...now I am running DNN that comes with Telerik v2013.1.403.40

The problem is that when I click on a button inside the RADGrid and the ItemCommand event fires, previously I was able to obtain the value of each cell in the row that the button was activated in. The *same exact code* running in v2013.1.403.40 of Telerick now returns to me "&nbsp;" for every single cell in the row. It's like the new Telerik version doesn't bind the data to the GridDataItem (e.Item) within the ItemCommand event like it used to.

What am I missing? How do I get the selected row's data like I had before?

Ben
Top achievements
Rank 1
 answered on 20 Aug 2015
1 answer
118 views

I have a HTMLChart that I would like to allow a user to right click on a point on the graph and set a start date and then right click on a second point and set the end date.  After the points are set it would then pass the dates into a stored procedure and update the HTMLChart.  How would I go about doing this?  The chart is currently being populated via server-side code.

<telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Visible="false" Legend-Appearance-Position="Top" Width="95%">
                            <ClientEvents OnLoad="BottomXAxisLabels" OnSeriesClick="OnSeriesClick" />
                            <PlotArea>
                                <Series>
                                    <telerik:ScatterLineSeries DataFieldY="ReturnedValue" DataFieldX="cycle_Date">
                                        <TooltipsAppearance Color="White" >
                                        </TooltipsAppearance>
                                        <LabelsAppearance Visible="false">
                                        </LabelsAppearance>
                                    </telerik:ScatterLineSeries>
                                </Series>
                                <YAxis>
                                    <LabelsAppearance>
                                        <TextStyle Bold="true" />
                                    </LabelsAppearance>
                                    <MinorGridLines Visible="false"></MinorGridLines>
                                    <MajorGridLines Visible="false"></MajorGridLines>
                                </YAxis>
                                <XAxis DataLabelsField="cycle_Date" BaseUnit="Years" MajorTickSize="1" >
                                    <LabelsAppearance Visible="true" RotationAngle="90" DataFormatString="Year {0:yyyy}">
                                        <TextStyle Bold="true" />
                                    </LabelsAppearance>
                                    <TitleAppearance Text="Dates">
                                        <TextStyle Bold="true" />
                                    </TitleAppearance>
                                    <MinorGridLines Visible="false"></MinorGridLines>
                                    <MajorGridLines Visible="true"></MajorGridLines>
                                </XAxis>
                            </PlotArea>
                            <ChartTitle>
                                <Appearance>
                                    <TextStyle Bold="true" />
                                </Appearance>
                            </ChartTitle>
                            <Legend>
                                <Appearance Visible="true" Position="Bottom"></Appearance>
                            </Legend>
                        </telerik:RadHtmlChart>
                    </telerik:RadAjaxPanel>

Danail Vasilev
Telerik team
 answered on 20 Aug 2015
2 answers
156 views

Hi

Is it posible to set the styling of the input field of a RadComboBox depending on wether a pre-selected item is enabled og disabled?

RMM
Top achievements
Rank 1
 answered on 20 Aug 2015
1 answer
98 views

Hi,

I have a single series column chart & I want to remove all the column names on the x-axis for space reasons. How can I put those names in a Legend box underneath the chart?

Danail Vasilev
Telerik team
 answered on 20 Aug 2015
3 answers
204 views

I got a gridview which I created with following code when user clicked one of treview node I have to populate a radgrid for given departmen. I dont know how can I catch treeview click event and without making any postback populate radgrid for clicked departmen. All help will be apreciated, thank you in advance.

    //Load Root Nodes...  
    private void LoadRootNodes()  
    {  
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personelcon"].ConnectionString);  
        SqlCommand selectCommand = new SqlCommand("SELECT * FROM Department WHERE Reportsto IS NULL", connection);  
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);  
        DataTable data = new DataTable();  
        adapter.Fill(data);  
 
        foreach (DataRow row in data.Rows)  
        {  
            RadTreeNode node = new RadTreeNode();  
            node.ImageUrl = "themes/default/entity.gif";  
            node.Text = row["Dname"].ToString();  
            node.Value = row["Departmenid"].ToString();  
            node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;  
            RadTreeView1.Nodes.Add(node);  
        }  
    } 
Peter Filipov
Telerik team
 answered on 20 Aug 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?