Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
111 views
I have a rad grid on my web page and what I want to do is inline editing on only a few cells in a row.  When the quantity cell is changed, I would like to be able to make some calculations and change some of the other cells in the grid that are read only.  I have the grid up and have the edit button, but I don't know how to get those values to change the other cells before it updates the database.  I've tried a couple different ways and the only values I get are   for every cell. 
Here's my source code for the grid and sqldatasource.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" 
            Skin="Telerik" AllowAutomaticDeletes="True" 
            DataSourceID="SqlDataSourceQuoteItems" GridLines="None" 
            AllowAutomaticInserts="True" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted">
<MasterTableView DataSourceID="SqlDataSourceQuoteItems" CommandItemDisplay="TopAndBottom" AutoGenerateColumns="False"
                DataKeyNames="id">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
     <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id" 
            ReadOnly="True" SortExpression="id" UniqueName="id" Visible="False">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="QuoteNo" HeaderText="QuoteNo" 
            SortExpression="QuoteNo" UniqueName="QuoteNo" Visible="False">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Room" HeaderText="Room" 
            SortExpression="Room" UniqueName="Room" ColumnEditorID="GridTextBoxRoom">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Elevation" HeaderText="Elevation" 
            SortExpression="Elevation" UniqueName="Elevation" ColumnEditorID="GridTextBoxElevation">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="PartNo" HeaderText="PartNo" 
            SortExpression="PartNo" UniqueName="PartNo" ColumnEditorID="GridTextBoxPartNo" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Qty" DataType="System.Double" 
            HeaderText="Qty" SortExpression="Qty" UniqueName="Qty" ColumnEditorID="GridNumericQty">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ListPrice" DataType="System.Double" 
            HeaderText="Price" SortExpression="ListPrice" UniqueName="ListPrice" ColumnEditorID="GridTextBoxListPrice" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="TotalPrice" DataType="System.Double" 
            HeaderText="Total Price" SortExpression="TotalPrice" UniqueName="TotalPrice"  ColumnEditorID="GridTextBoxTotalPrice" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="EachWeight" DataType="System.Double" 
            HeaderText="Weight" SortExpression="EachWeight" UniqueName="EachWeight" ColumnEditorID="GridTextBoxEachWeight" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="TotalWeight" DataType="System.Double" 
            HeaderText="Total Weight" SortExpression="TotalWeight" UniqueName="TotalWeight" ColumnEditorID="GridTextBoxTotalWeight" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="EachCubes" DataType="System.Double" 
            HeaderText="Cubes" SortExpression="EachCubes" UniqueName="EachCubes" ColumnEditorID="GridTextBoxEachCubes" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="TotalCubes" DataType="System.Double" 
            HeaderText="Total Cubes" SortExpression="TotalCubes" UniqueName="TotalCubes" ColumnEditorID="GridTextBoxTotalCubes" ReadOnly="true">
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
    </Columns>
     <EditFormSettings ColumnNumber="7" CaptionDataField="PartNo" CaptionFormatString="Edit properties of Product {0}">
        <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Product" UpdateText="Update record"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
     </EditFormSettings>
</MasterTableView>
  
 <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
          
         <telerik:GridTextBoxColumnEditor ID="GridTextBoxRoom" runat="server" TextBoxStyle-Width="25px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxElevation" runat="server" TextBoxStyle-width="25px" />
             <telerik:GridTextBoxColumnEditor ID="GridTextBoxPartNo" runat="server" TextBoxStyle-width="90px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxListPrice" runat="server" TextBoxStyle-width="45px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxTotalPrice" runat="server" TextBoxStyle-width="45px" />
             <telerik:GridTextBoxColumnEditor ID="GridTextBoxEachWeight" runat="server" TextBoxStyle-width="35px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxTotalWeight" runat="server" TextBoxStyle-width="35px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxEachCubes" runat="server" TextBoxStyle-width="40px" />
            <telerik:GridTextBoxColumnEditor ID="GridTextBoxTotalCubes" runat="server" TextBoxStyle-width="40px" />
            <telerik:GridTextBoxColumnEditor ID="GridNumericQty" runat="server" TextBoxStyle-width="35px" />
            <telerik:RadWindowManager ID="RadWindowManager2" runat="server"></telerik:RadWindowManager>
          
        <asp:SqlDataSource ID="SqlDataSourceQuoteItems" runat="server" 
            ConnectionString="Data Source=DWDATA2;Initial Catalog=DWJobInfo;Integrated Security=True" 
            ProviderName="System.Data.SqlClient" 
              
            SelectCommand="SELECT * FROM [tblMetalCabsQuoteItems] WHERE ([QuoteNo] = @QuoteNo) ORDER BY [Room], [Elevation]" 
            DeleteCommand="DELETE FROM tblMetalCabsItems WHERE id = @id">
            <SelectParameters>
                <asp:ControlParameter ControlID="lblQuoteNo" Name="QuoteNo" PropertyName="Text" 
                    Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="id" Type="Int16" />
            </DeleteParameters>
        </asp:SqlDataSource>

I know I have to add some parameters for the update sqldatasource yet.  But I figured I have to figure out this problem before i can even think about doing that part of it yet.  So, when I click edit and change the values I need to, how do I grab all the values to do some calculations and then to update the database to then refresh the grid?
Princy
Top achievements
Rank 2
 answered on 17 Dec 2010
3 answers
162 views

Folks, Using Telerik ASP.NET Ajax 2010 built 3 with VS 2010.

I have a hierachal radgrid. I would like to prevent users with an alert message to expand the Row without selecting the Row 1st.

For example, if Parent row 1 is selected, then if I click to expand Parent row 2 without selecting Parent row 2
-- Although Parent row 1 is still selected, but Parent row 2 expands.

I understand from this for single/expand:
http://www.telerik.com/help/aspnet-ajax/grdsingleexpandinhierarchicalgrid.html

Basically

- Attached file is my desire result (Child Expanded After Parent Row Highlighted.JPG)

- Attached file is NOT my desire result (Child Expanded without Parent Row Highlighted.JPG)

Thanks.
GC_0620

Princy
Top achievements
Rank 2
 answered on 17 Dec 2010
13 answers
1.1K+ views
Hi,

I have a GridClientSelectColumn in a RadGrid. When a client selects a row, I would like to retrieve a value from the selected row and save it to a variable. I have tried using the ItemCreated, ItemCommand, and ItemEvent. So far I've had no luck... any suggestions would be appreciated.

Thanks,

Jack   
Catherine
Top achievements
Rank 1
 answered on 17 Dec 2010
1 answer
80 views
Hi,

Is export option is there with tree list.if so how?
Daniel
Telerik team
 answered on 17 Dec 2010
1 answer
118 views
Hi all,

I was wondering is it possible to export the RadGrid to Excel like the one in this demo (http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultvb.aspx). (See 1.png and 2.png attachments)

At the moment, my page replicates the demo pretty closely. Unlike the demo, the three RadTabs all contains a RadGrid with relations to the main RadGrid. I want to be able to export each of these RadGrids independently. Each RadPageView will contain a button and a RadGrid. The button will export the RadGrid in that RadPageView only.

My problem right now is I cannot address the button or RadGrid inside the NestedViewTemplate from code behind. Could this be done?

Thanks,
Gary
Daniel
Telerik team
 answered on 17 Dec 2010
4 answers
394 views
Hi All,
I am battling to get the RadUpload control working in a EditItemTemplate.
I have followed the examples, tried other solutions from the forums, but to no avail.
After stripping everything back I have the following error :
Server Error in '/' Application.
--------------------------------------------------------------------------------
  
Invalid JSON primitive: C. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
Exception Details: System.ArgumentException: Invalid JSON primitive: C.
  
Source Error: 
  
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
Stack Trace: 
  
  
[ArgumentException: Invalid JSON primitive: C.]
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() +562290
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +263
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +80
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +44
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(String input) +74
   Telerik.Web.UI.RadUpload.LoadPostData(String postDataKey, NameValueCollection postCollection) +149
   Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +42
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +8910120
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878
  
   
  
  
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

It must be a problem with my base understanding of the controls, since there really isn't much to my attempts.  Below I have included my stand-alone test aspx and code behind :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadTesting.aspx.cs"
    Inherits="Audit.Testing.UploadTesting" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function conditionalPostback(sender, eventArgs) {
                var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                if (eventArgs.get_eventTarget().match(theRegexp)) {
                    if (upload && upload.getFileInputs()[0].value != "") {
                        alert('ajax off');
                        eventArgs.EnableAjax = false;
                    }
                }
            }
  
            var upload = null;
  
            function uploadFileSelected(sender, args) {
                upload = sender;
                var uploadContainer = sender.get_element();
                var editTable = uploadContainer.parentNode.parentNode.parentNode.parentNode;
                var fileNameTextBox = editTable.rows[0].cells[1].getElementsByTagName('input')[0];
  
                fileNameTextBox.value = args.get_fileInputField().title;
            }
  
  
        </script>
    </telerik:RadCodeBlock>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None"
            OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnInsertCommand="RadGrid1_InsertCommand">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id">
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="File" UniqueName="FileUploader">
                        <EditItemTemplate>
                            <telerik:RadUpload ID="FileUploader" runat="server" ControlObjectsVisibility="RemoveButtons"
                                MaxFileInputsCount="1" MaxFileSize="4000000" >
                            </telerik:RadUpload>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblFilename" runat="server" Text='<%# Eval("Filename") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:RadGrid>
    </div>
    <telerik:RadAjaxManager runat="server">
    </telerik:RadAjaxManager>
    </form>
</body>
</html>

Code behind :
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;
  
namespace Audit.Testing
{
    public partial class UploadTesting : System.Web.UI.Page
    {
  
          
        protected DataTable TheData
        {
            get
            {
                if (Session["TheData"] == null)
                {
                    DataTable dt = new DataTable();
                    DataColumn dcFilename = new DataColumn();
                    dcFilename.ColumnName = "Filename";
                    dcFilename.DataType = System.Type.GetType("System.String");
                    dt.Columns.Add(dcFilename);
                    DataColumn dcFiledata = new DataColumn();
                    dcFiledata.ColumnName = "FileData";
                    dcFiledata.DataType = typeof(byte[]);
                    dt.Columns.Add(dcFiledata); 
                            DataColumn dcId = new DataColumn(); 
                            dcId.ColumnName = "Id"; 
                            dcId.DataType = typeof(int); 
                            dt.Columns.Add(dcId);
  
                    Session["TheData"] = dt;
                }
                return (DataTable)Session["TheData"];
                  
            }
            set
            {
                Session["TheData"] = value;
            }
        }
  
        public string GetApplicationPath()
        {
            IMSCommonLibrary.Utilities.Objects.Globals gb = new IMSCommonLibrary.Utilities.Objects.Globals();
            return gb.Get_Server_Prefix();
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
  
        }
  
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            RadGrid1.DataSource = TheData;
        }
  
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem gei = e.Item as GridEditableItem;
                ((RadUpload)gei.FindControl("FileUploader")).OnClientFileSelected = "uploadFileSelected";
            }
        }
  
        protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
        {
  
        }
    }
}

Can anyone steer me in the right direction here?  I have had no success with the GridAttachmentColumn either, so please give feedback to my design as stated.  I am not able to use SQLDataSource controls for this purpose, with datasets/datatables being my only communications with the data-layer/db.
Thanks,
Steele.

*Edit* Telerik version is 2010.3.1109.40
Steele
Top achievements
Rank 1
 answered on 17 Dec 2010
3 answers
72 views
Seems like this should be so easy...

I'm defining a <TimeSlotContextMenus> tag within the body of my RadScheduler.  Within one of the functions callable from that menu, I need to be able to access the targetSlot at which the context menu actually appeared.  I tried adding a custom OnClientTimeSlotContextMenu to my page, but this function never seems to get called at all (although the context menu appears fine).  What's up?

<telerik:RadScheduler
    ID="RadSchedulerCalendarEvents"
    runat="server"
    Width="100%"
    Height="500"
    BorderStyle="None"
    BorderWidth="0"
    HoursPanelTimeFormat="h:mm tt"
    ShowFullTime="true"
    TimeSlotContextMenuSettings-EnableDefault="true"
    StartInsertingInAdvancedForm="true"
    DisplayRecurrenceActionDialogOnMove="true"
    EnableDatePicker="False"
    EnableDescriptionField="True"
    DataSourceID="SqlDataSourceEvents"
    DataKeyField="evtID"
    DataStartField="evtStartTime"
    DataEndField="evtEndTime"
    DataSubjectField="evtName"
    DataDescriptionField="evtDescription"
    DataReminderField="evtReminder"
    DataRecurrenceField="evtRecurrenceRule"
    DataRecurrenceParentKeyField="evtRecurrenceParentID"
    OnAppointmentDelete="RadSchedulerCalendarEvents_AppointmentDelete"
    OnAppointmentUpdate="RadSchedulerCalendarEvents_AppointmentUpdate"
    OnAppointmentInsert="RadSchedulerCalendarEvents_AppointmentInsert"
    OnClientAppointmentInserting="RadSchedulerCalendarEvents_OnClientAppointmentInserting"
    OnClientAppointmentEditing="RadSchedulerCalendarEvents_OnClientAppointmentEditing"
    OnClientAppointmentMoveEnd="RadSchedulerCalendarEvents_OnClientAppointmentMoveEnd"
    OnClientAppointmentResizeEnd="RadSchedulerCalendarEvents_OnClientAppointmentResizeEnd"
    >
    <AdvancedForm Modal="true" />
    <TimeSlotContextMenus>
        <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerTimeSlotContextMenu">
            <Items>
                <telerik:RadMenuItem Text="New Event" ImageUrl="/Images/Icons16x16/calendar.png" Postback="false" NavigateUrl="javascript: SwitchToCalendarEventInsertForm(null, null);" />
                <%--<telerik:RadMenuItem Text="New Recurring Event" ImageUrl="/Images/Icons16x16/recurring-event.png" NavigateUrl="javascript: alert('upmp');" />--%>
                <%--<telerik:RadMenuItem IsSeparator="true" />--%>
                <%--<telerik:RadMenuItem Text="Group by Calendar" Value="EnableGrouping" />--%>
                <telerik:RadMenuItem IsSeparator="true" />
                <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
            </Items>
        </telerik:RadSchedulerContextMenu>
    </TimeSlotContextMenus>
    <AppointmentContextMenuSettings EnableDefault="true" />
    <Localization
        ContextMenuAddAppointment="New Event"
        ContextMenuAddRecurringAppointment="New Recurring Event"
        ContextMenuEdit="Edit Event" />
</telerik:RadScheduler>
Jesse Lawler
Top achievements
Rank 1
 answered on 16 Dec 2010
1 answer
73 views
Hello, 

I want to cut the text in my columns if they exceed the column's width (to display them in a tool-tip) .
 My columns are all GridBoundColumns, ive tried to set their width on the WIDTH propriety but it didn't work.

Thanks
Cori
Top achievements
Rank 2
 answered on 16 Dec 2010
1 answer
173 views
I have a page, let's call this main.aspx. Within main.aspx I have a splitter and load content into let's say [header] frame and [content] frame. I also have a RadWindow on main.aspx that I call to open for errors.

Within the [content] frame I have a grid using a edit Template to edit rows of the grid. If an update fails I reference and open the RadWindow using a method such as this:
var op = parent;         
var oWnd = op.GetRadMessageWindow()
oWnd.moveTo(-1000,-1000) 
oWnd.add_pageLoad(OnClientLoadMsg);
oWnd.add_close(OnClientCloseMsg);          
oWnd.setUrl("RTS_Message_Window.aspx");
oWnd.show();

The problem is that none of the server-side Page events are NOT being fired. 
I can see that the content is being loaded and I can debug client side window load events but why are the server-side events not being fired? 
This used to work. I imagine this stopped working after Ajax 2009 Q3 release.
Robert
Top achievements
Rank 1
 answered on 16 Dec 2010
4 answers
185 views

Hi. Could you provide me with the localization (internationalization) keys for the tooltips in the "Next page" and "Last page" buttons and "page" and "items" labels in the footer of the RadGrid and RadFileExplorer controls?

Also I don't know whether I'm supposed to put them in "RadEditor.Dialogs.resx" or "RadGrid.Main.resx".

Thanks in advance.

Diego Pazos
Top achievements
Rank 1
 answered on 16 Dec 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?