Telerik Forums
UI for ASP.NET AJAX Forum
12 answers
815 views
I'd like know how to use CalculatedColumn in Batch Editing mode. The most common scenario is UnitPrice * Quantity = Total Price. 

CalculatedColumn works fine in first inquiry. But when grid in Batch Editing mode, the Calculated Column in Client side has no mechanism to  automatically calculate.  I try to update total price cell  by java code, but I found there is no way to find the element. 

Please kindly help me to implement this. 

With best regards

Jason
Eyup
Telerik team
 answered on 14 Jan 2019
1 answer
578 views
I have added UpdatePanel to include a grid in order to reflect some changes. However, when I click other buttons on the page to update some data and the grid will disappear after postback. 

I try to remove the UpdatePanel, then the grid will be shown and data will be shown on the grid. 

Here is my code. 

Mainly, when the page first comes in, the grid will be shown with data. However, when I click a button on the page to update some data, and the update should be shown on the grid. The page is a postback, however, when I do this, the grid will not be shown. 

I try to remove the UpdatePanel in , then when I click the button on the page to update data, the grid will be shown again. It seems the UpdatePanel has made the grid disappear. I need to keep the UpdatePanel and make the grid not disappeared after I click the button on the page and post back.

        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
       <ContentTemplate>
          <telerik:RadGrid ID="uiGrid" runat="server"
             AutoGenerateColumns="false" ItemStyle-BackColor="White" AlternatingItemStyle-BackColor="White"
             OnDataBound="uiGrid_DataBound" OnItemDataBound="uiGrid_ItemDataBound" OnNeedDataSource="uiGrid_NeedDataSource"
             ClientSettings-ClientEvents-OnKeyPress="keyPressInGrid"
             Width="100%" Height="500" EnableViewState="true">
             <ClientSettings>
                <Scrolling CountGroupSplitterColumnAsFrozen="false" AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="3"></Scrolling>
             </ClientSettings>
             <MasterTableView>
                <GroupByExpressions>
                   <telerik:GridGroupByExpression>
                      <SelectFields>
                         <telerik:GridGroupByField FieldAlias="<%$ Resources:Resource,Group %>" FieldName="IndicatorParentName"></telerik:GridGroupByField>
                      </SelectFields>
                      <GroupByFields>
                         <telerik:GridGroupByField FieldName="IndicatorParentName" SortOrder="Ascending"></telerik:GridGroupByField>
                      </GroupByFields>
                   </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                   <telerik:GridBoundColumn DataField="IndicatorName" HeaderText="<%$ Resources:Resource,Indicator %>" UniqueName="IndicatorName"
                      SortExpression="IndicatorName" DataType="System.String" ItemStyle-Wrap="false">
                   </telerik:GridBoundColumn>
                   <telerik:GridTemplateColumn>
                      <ItemTemplate>
                         <asp:HiddenField ID="uiIndicatorID" runat="server" Value='<%#Eval("IndicatorID")%>' />
                         <asp:HiddenField ID="uiIndicatorName" runat="server" Value='<%#Eval("IndicatorName")%>' />
                         <asp:ImageButton ID="uiTipsButton" runat="server" ImageUrl="images/information-icon.png?20170703" Width="16" Height="16" />
                      </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn HeaderText="<%$ Resources:Resource,Unit %>">
                      <ItemTemplate>
                         <asp:Label ID="uiUnit" runat="server" />
                      </ItemTemplate>
                   </telerik:GridTemplateColumn>
                </Columns>
             </MasterTableView>
          </telerik:RadGrid>
       </ContentTemplate>
    </asp:UpdatePanel>

And here is the code behind :

    protected void uiImport_Click(object sender, EventArgs e)
        {
            // clear message
            uiErrorMsg.Text = "";
            uiSuccessMsg2.Text = "";

            StringBuilder message = new StringBuilder(1024);

            HttpResponseMessage result = null;

            if (uiUpload.UploadedFiles.Count > 0)
            {
                result = ImportData();

                if (result.IsSuccessStatusCode)
                {
                    message.Append(Convert.ToString(HttpContext.GetGlobalResourceObject("Resource", "Message_Import_Data_Successful")));
                    message.Append(Environment.NewLine);
                    try
                    {
                        _usageData.Dispose();
                        _usageData = null;
                    }
                    catch { }
                    
                    BindGrid(true); // refresh grid.

                    // update task modified by and date
                    bool hasError = false;
                    Common.Systems.Sustainability.Constants.ApprovalStatuses status = Common.Systems.Sustainability.Constants.ApprovalStatuses.Undefined;
                    bool isApprovedOrRejected = WorkflowUtil.IsApprovedOrRejected(_taskID.Value, ref status);
                    if (isApprovedOrRejected)
                    {
                        // re-cache data for dashboards
                        int companyID = Common.WebUtil.GetCompanyID();
                        Thread childThread = new Thread(() => Util.ReCacheForDashboards(Cache, companyID));
                        childThread.Start();
                    }
                    else
                    {
                        UpdateTask(ref hasError);
                    }
                }
                else
                {
                    string msg = Convert.ToString(HttpContext.GetGlobalResourceObject("Resource", "Message_Unable_To_Import_Data"));
                    message.Append(msg);
                    message.Append(Environment.NewLine);

                    string resultMessage = result.Content.ReadAsStringAsync().Result;
                    if (resultMessage.IndexOf("ExceptionMessage", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        resultMessage = resultMessage.Replace("\\r\\n", "<br />");
                        Logger.Log(string.Format("Error occurs in the '{0}.{1}' method.{2}{3}"
                            , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()
                            , System.Reflection.MethodBase.GetCurrentMethod().Name
                            , Environment.NewLine
                            , resultMessage));
                    }
                    else
                    {
                        message.Append(Common.Util.ReformatMessage(resultMessage));
                    }
                } // end if
            } // end if

            if (result != null)
            {
                if (result.IsSuccessStatusCode)
                {
                    uiSuccessMsg2.Text = message.Replace(Environment.NewLine, "<br />").ToString();
                }
                else
                {
                    // show error message on web.
                    //uiErrorMsg.Text = message.Replace(Environment.NewLine, "<br />").ToString();
                    //uiPanel2.Alert(message.ToString());
                    uiReportPanel.Alert(message.ToString());
                } // end if
            } // end if
        }


    private void BindGrid(bool performDataBind = true)
        {
            DataTable locationsTable = null;
            DataTable indicatorsTable = null;
            try
            {
                // try to get delegation, location and indicators information, it contains order of locations and indicators
                // order numbers will be for sorting in below
                try
                {
                    _delegation = GetDelegationByTaskID(_taskID.Value);
                    int delegationID = Convert.ToInt32(_delegation.Tables[0].Rows[0][Common.Systems.Sustainability.Constants.Delegation.ID]);
                    _delegationLocationsAndIndicators = GetDelegationLocationsAndIndicatorsByDelegationID(delegationID);
                }
                catch { }

                // remove all columns
                for (int i = 3; i < uiGrid.MasterTableView.Columns.Count; i++)
                {
                    GridColumn col = uiGrid.MasterTableView.Columns[i];
                    uiGrid.MasterTableView.Columns.Remove(col);
                    i--;
                }

                DataSet usage = GetUsageData();
                //using (DataSet usage = GetUsageData())
                //{
                
                {
                    locationsTable = usage.Tables[0].DefaultView.ToTable(true, new string[] {
                            Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID
                            , Common.Systems.Sustainability.Constants.Location.LocationName
                        }
                    );

                    // As requested by user in 2016-07, sorting location and indicator based on delegation selected ordering.
                    if (_delegationLocationsAndIndicators != null)
                    {
                        locationsTable.Columns.Add(Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation, Type.GetType("System.Int32"));
                        foreach (DataRow dr in locationsTable.Rows)
                        {
                            DataRow[] dli = _delegationLocationsAndIndicators.Tables[0].Select(string.Format("{0} = {1}"
                                        , Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID
                                        , dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID]
                                    ));
                            if (dli.Length > 0)
                            {
                                int? sequence =  .Common.Util.TryToConvertToInt32(dli[0],  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation);
                                if (sequence != null)
                                {
                                    dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation] = sequence.Value;
                                }
                            }
                        }

                        locationsTable.DefaultView.Sort =  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation;
                        DataTable temp = locationsTable.DefaultView.ToTable();
                        locationsTable.Dispose();
                        locationsTable = temp;
                    }


                    // append locations to grid view
                    int i = 0;
                    foreach (DataRow dr in locationsTable.Rows)
                    {
                        string locationID = Convert.ToString(dr["LocationID"]);
                        string locationName = Convert.ToString(dr["LocationName"]);

                        GridTemplateColumn tplColumn = new GridTemplateColumn();
                        tplColumn.ItemTemplate = new UsageColumnTemplate(locationName, i.ToString(), locationID, _currencies);
                        tplColumn.HeaderText = locationName;
                        uiGrid.MasterTableView.Columns.Add(tplColumn);

                        i++;
                    }

                    
                }


                // filter out indicators if no location associated
                {
                    indicatorsTable = usage.Tables[0].DefaultView.ToTable(true, new string[] {
                             .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID
                            ,  .Common.Systems.Sustainability.Constants.Indicator.IndicatorName
                            , "IndicatorParentName" // Added by HC on 2016-06-08, as requested by users, use parent indicator name as group on the grid view.
                        }
                    );

                    // As requested by user in 2016-07, sorting location and indicator based on delegation selected ordering.
                    if (_delegationLocationsAndIndicators != null)
                    {
                        indicatorsTable.Columns.Add( .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator, Type.GetType("System.Int32"));
                        foreach (DataRow dr in indicatorsTable.Rows)
                        {
                            DataRow[] dli = _delegationLocationsAndIndicators.Tables[0].Select(string.Format("{0} = {1}"
                                        ,  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID
                                        , dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID]
                                    ));
                            if (dli.Length > 0)
                            {
                                int? sequence =  .Common.Util.TryToConvertToInt32(dli[0],  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator);
                                if (sequence != null)
                                {
                                    dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator] = sequence.Value;
                                }
                            }
                        }

                        indicatorsTable.DefaultView.Sort =  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator;
                        DataTable temp = indicatorsTable.DefaultView.ToTable();
                        indicatorsTable.Dispose();
                        indicatorsTable = temp;
                    }

                    // bind indicators to grid view
                    uiGrid.DataSource = indicatorsTable;
                    //if (performDataBind)
                    //uiGrid.Rebind();
                }
                    
                //} // end using
            }
            finally
            {
                if (locationsTable != null)
                {
                    locationsTable.Dispose();
                    locationsTable = null;
                }
                if (indicatorsTable != null)
                {
                    indicatorsTable.Dispose();
                    indicatorsTable = null;
                }
            }
        }
Eyup
Telerik team
 answered on 14 Jan 2019
4 answers
527 views
How can I stop the mouse scroll wheel incrementing and decrementing the values of a GridNumericColumn in my Radrgrid when EditMode="Batch" and EditType="Cell"?

This post suggests using ItemDataBound: http://www.telerik.com/forums/gridnumericcolumn-edit-control
However if I step into the debugger the code:
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
is never True

Hope you can help?
Eyup
Telerik team
 answered on 14 Jan 2019
1 answer
141 views

I'm basing my page on your car rental demo for the grid. This is the demo that opens a NestedViewTemplate when you click a row.

The Container property is used to get the file url for the image for the car. My problem is that in my application I have several images. I want to just iterate over the image urls using inline C# code to insert the images. But I can't use the Container property in the inline code.

 

<%

// Container is undefined here

// What I want to do is call something like

List<string> urls = GetTheUrls(Container);

for (int i = 1; i < urls.Count; ++i) { %>

<asp:Image runat="server" AlternateText="Car Image" ImageUrl='<%# files[i]%>' Height="400px" />

<% } %>

%>

So what do I do?

I hope this is a clear enough request.

 

 

Paul
Top achievements
Rank 1
 answered on 14 Jan 2019
10 answers
255 views

HI

I'm designing a news site and using radeditor. As I showed in the picture in an accurate error while working properly, I could not find the answer in the forum, I'm waiting for your help.

İsmail
Top achievements
Rank 1
 answered on 11 Jan 2019
1 answer
203 views

hi,

 

I am trying to figure upload async out using Batch edit.

I works like a charm on this Demo using row edit:

https://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandradasyncupload/defaultcs.aspx?product=grid

 

Is it possible to upload a single file to a varbinary on Batch edit?

 

Thx,

Valerio

 

Vessy
Telerik team
 answered on 10 Jan 2019
3 answers
151 views

Hi,

i have an issue with NumericTextBox.

when the NumericTextBox has spinbuttons enabled, then its width are not taking in account and overlays the value and during editing the cancel-button as well. i am using Microsoft Windows 10 (1809) and its Microsoft Edge.

here the code-snip:

<telerik:RadNumericTextBox ID="RadNumericTextBox1"
    runat="server"
    MinValue="0" MaxValue="100"
    DbValue='<%# Eval("test") %>'
    ShowSpinButtons="False"
    NumberFormat-AllowRounding="False"
    ReadOnlyStyle-HorizontalAlign="Right"
    NegativeStyle-HorizontalAlign="Right"
    InvalidStyle-HorizontalAlign="Right"
    HoveredStyle-HorizontalAlign="Right"
    FocusedStyle-HorizontalAlign="Right"
    EnabledStyle-HorizontalAlign="Right"
    EmptyMessageStyle-HorizontalAlign="Right"
    DisabledStyle-HorizontalAlign="Right"
    />

Same  behaviour, when using CcsClass style to align the value to the right.

 

 

Dev
Top achievements
Rank 1
 answered on 10 Jan 2019
4 answers
211 views

Hi,

How I can render a icon from a custom font inside of a button using a <i> tag?

<telerik:RadButton ID="btSearch" runat="server" Primary="true" Text="<i class='zmdi zmdi-search'></i> Search" EnableEmbeddedSkins="false" OnClick="btSearch_Click"></telerik:RadButton>

Attached is the problem and the button (objective) I want to accomplish.

 

Thanks

Marin Bratanov
Telerik team
 answered on 10 Jan 2019
1 answer
85 views

When I select timeslots, using the left mouse button and dragging, those timeslots will be incorrectly choosen on a scrolled down webpage.

The screenshot is attached.

This picture shows the end of a mouse drag operation, starting with the timeslot above the current one, so 2 timeslots should have been choosen (instead of 6).

Why? What can I do about it?

This question is also asked on

https://stackoverflow.com/questions/53871128/selecting-timeslots-in-radscheduler-on-webpage-initially-scrolled-down-results-i

 

Anders
Top achievements
Rank 1
 answered on 10 Jan 2019
4 answers
125 views

     Hello, 

 

I have a RadDock in a RadZoneDock and when I put a RadAjaxPanel that encompasses the entire page, one of my docks goes blank (see attachment).  When remove Ajax, it works.  What should I look at please?

 

<telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel" Width="100%">

Page content.

</telerik:RadAjaxPanel>

 

Thank you,

Josh

Attila Antal
Telerik team
 answered on 09 Jan 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?