Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
124 views

Hi,

I am facing issue to getting GridDataItem on ItemRequested Event. My scenario is

In RadGrid, EditItemTemplate has one RadComboBox "rcbEmployee" and this RadComboBox bind on rcbEmployee_ItemsRequested event by calling one method "GetEmployee" that fatch the employee list to bind RadComboBox.

But "GetEmployee" method needed some parameter those can be get by GridDataItem. 

So How can I access GridDataItem on "rcbEmployee_ItemsRequested" event or is there any work around ?

<telerik:RadGrid ID="RadGrid12" runat="server" MasterTableView-DataKeyNames="iIndex,pEmployee,FirstName" MasterTableView-ClientDataKeyNames="iIndex,pEmployee,FirstName"
                EnableLinqExpressions="false" ClientSettings-EnableRowHoverStyle="true" Width="100%" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" OnNeedDataSource="RadGrid1_NeedDataSource"
                AllowMultiRowSelection="true" AllowAutomaticUpdates="True" AutoGenerateColumns="False" >
                <MasterTableView GridLines="Both" HeaderStyle-HorizontalAlign="Center" AutoGenerateColumns="false"
                    CommandItemDisplay="None" HorizontalAlign="NotSet">
                     <Columns>
                        <telerik:GridTemplateColumn DataField="FirstName" ItemStyle-Width="200px" HeaderStyle-Width="200px" HeaderText="Name" UniqueName="FirstName">
                            <ItemTemplate>
                                <asp:Label ID="lblFirstName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FirstName")%>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadComboBox runat="server" ID="rcbEmployee" EnableLoadOnDemand="True" DataTextField="Name" DataValueField="iIndex"
                                    OnItemsRequested="rcbEmployee_ItemsRequested" AutoPostBack="false" HighlightTemplatedItems="true" Height="300px" Width="180px" DropDownWidth="180px">
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container, "Text")%>
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                            </EditItemTemplate>
                            <FilterTemplate></FilterTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>

 

Please help.

Thanks,

Sachin

 

 

sachin
Top achievements
Rank 1
 asked on 15 Nov 2017
2 answers
132 views
I have a numeric textbox.  If I was to enter 123456789112345.67 in it, the control changes the value to 703687441776.64.  This behavior can be seen in your online demo as well (https://demos.telerik.com/aspnet-ajax/numerictextbox/overview/defaultcs.aspx).  Why does that happen?
Stacy
Top achievements
Rank 1
 answered on 15 Nov 2017
0 answers
176 views

So i am using a RadGrid in a custom control. In the java script i am binding the grids events to events declared in my custom control. The issue is the rowCreated function is not firing until i actually click a row. Since its within a prototype i have to create it as a delegate to ensure i can still access other variables in the same scope.

grid.add_rowCreated(Function.createDelegate(this, this.rowCreated));

 

But this causes the rowCreated event to not fire until i interact with the grid by selecting a row. Could someone give me some guidance on this please, it may be something obvious as i am fairly new to webforms controls. I have added the full code below, but have cut it down to be relevant.

Type.registerNamespace("WebApp.Portal.Controls");
 
// Define the control properties.
WebApp.Portal.Controls.DataViewContainer = function (element) {
    WebApp.Portal.Controls.DataViewContainer.initializeBase(this, [element]);
    this._clientId = null;
    this._radGridId = null;
    this._keyColumnName = null;
    this._idsOfSelectedRows = [];
};
 
// Define the prototype
WebApp.Portal.Controls.DataViewContainer.prototype = {
 
    initialize: function (sender, eventArgs) {
        WebApp.Portal.Controls.DataViewContainer.callBaseMethod(this, 'initialize');
 
        // Will be called on ajax or full postback
        window.Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Function.createDelegate(this, this.onLoad));
        // If this is being executed by ajax
        if (eventArgs) {
            // And this is only a partial load
            if (eventArgs.get_isPartialLoad()) {
                // Don't perform any further processing
                return;
            }
        }
        // only hit on full postback.
        this.bindEvents();
    },
 
    dispose: function() {
        WebApp.Portal.Controls.DataViewContainer.callBaseMethod(this, 'dispose');
    },
     
    idsOfSelectedRows: [],
 
    //
    // Methods.
    //
    onLoad: function () {
    },
     
    bindEvents: function () {
        var grid = window.$find(this.get_radGridId());
        if (grid != undefined) {
            grid.add_rowSelected(Function.createDelegate(this, this.rowSelected));
            grid.add_rowDeselected(Function.createDelegate(this, this.rowDeselected));
            grid.add_rowCreated(Function.createDelegate(this, this.rowCreated));
            grid.add_gridCreated(Function.createDelegate(this, this.gridCreated));
        }
    },
 
    rowSelected : function(sender, args) {
        var entityId = args.getDataKeyValue(this._keyColumnName);
        this.updateIdsOfSelectedRows(entityId, true);
        console.log(JSON.stringify(this.idsOfSelectedRows));
    },
     
    rowDeselected : function (sender, args) {
        var entityId = args.getDataKeyValue(this._keyColumnName);
        this.updateIdsOfSelectedRows(entityId, false);
        console.log(JSON.stringify(this.idsOfSelectedRows));
    },
     
    rowCreated : function (sender, args) {
        var entityId = args.getDataKeyValue(this._keyColumnName);
        console.log("Row Created: " + entityId);
        if ($.inArray(entityId, this.idsOfSelectedRows) >= 0) {
            args.get_gridDataItem().set_selected(true);
        }
    },
     
    gridCreated : function (sender, eventArgs) {
        var masterTable = sender.get_masterTableView();
        var selectColumn = masterTable.getColumnByUniqueName("clmSelect");
        var headerCheckBox = $(selectColumn.get_element()).find("[type=checkbox]")[0];
        if (headerCheckBox) {
            headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_dataItems().length;
        }
    },
     
    updateIdsOfSelectedRows : function(id, isSelected) {
        var index = $.inArray(id, this.idsOfSelectedRows);
        if (!isSelected && index >= 0) {
            this.idsOfSelectedRows.splice(index, 1); // remove id from the list
        } else if (index < 0) {
            this.idsOfSelectedRows.push(id);
        }
    },
 
    //
    // Properties.
    //
    get_radGridId: function() {
        return this._radGridId;
    },
     
    set_radGridId: function(value) {
        if (this._radGridId !== value) {
            this._radGridId = value;
            this.raisePropertyChanged('_radGridId');
        }
    },
 
    get_clientId: function () {
        return this._clientId;
    },
 
    set_clientId: function (value) {
        if (this._clientId !== value) {
            this._clientId = value;
            this.raisePropertyChanged('clientId');
        }
    },
     
    get_keyColumnName: function () {
        return this._keyColumnName;
    },
 
    set_keyColumnName: function (value) {
        if (this._keyColumnName !== value) {
            this._keyColumnName = value;
            this.raisePropertyChanged('keyColumnName');
        }
    },
};
 
WebApp.Portal.Controls.DataViewContainer.registerClass('WebApp.Portal.Controls.DataViewContainer', Sys.UI.Control);

 

 

Tony
Top achievements
Rank 1
 asked on 15 Nov 2017
23 answers
728 views

Hi, I have the following button in the radgrid

 

  <telerik:GridButtonColumn CommandName="CustomDelCommand" ConfirmText="Delete this record?" ConfirmDialogType="RadWindow" ItemStyle-Width="18" HeaderStyle-Width="18"
                        ConfirmTitle="Delete" ButtonType="FontIconButton" >
                    </telerik:GridButtonColumn>

My item command code is here, the problem is the event not firing for chrome, safari. IE no problem. Anyone any idea?

 protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "CustomDelCommand")
            {
                MailAddress addr = new MailAddress(User.Identity.Name);
                string username = addr.User;
          var Id = (int)((GridDataItem)e.Item).GetDataKeyValue("id");

//del id record.
               
            }
        }

Pavlina
Telerik team
 answered on 15 Nov 2017
10 answers
2.5K+ views

One of our Grids is basically a build your own query page and can often return upwards of 50 pages of 50 items.

We want the select all checkbox to select all the items across all the returned pages. However, the default functionality is to only select what's on the current page.

The official workaround is to temporarily set the page size to that of the datasource.data().length, select all the items, then return the page size to what it was previously.

The problem is that grid.dataSource.pageSize() doesn't return a promise. It only returnsthe current page size... asynchronously and instantly. The example shown for the workaround, as far as I can tell, could never have worked.

Does anyone have a solution to selecting all items when you have several pages of data?

Preslav
Telerik team
 answered on 15 Nov 2017
1 answer
115 views

I've a Grid with one of the Columns "No. of Notes" which hold link int values.

When clicked on one of the value I want to open a window which shows already existing notes, who and when was the note entered and should allow the user to enter any new notes. The user shouldn't be able to edit existing notes.

Do you have any specific control to handle this? Or any suggestions on how to achieve this will be appreciated. 

Eyup
Telerik team
 answered on 15 Nov 2017
5 answers
185 views
We are using the Kendo UI Scheduler for MVC. Is there any way to integrate with exchange and display events in an outlook calendar? 
Plamen
Telerik team
 answered on 15 Nov 2017
2 answers
162 views

Hi team,

I've got issue when binding a dynamic Datatable to kendoGrid, the data of boolean column is auto converted to false when it's null.

Is there anyway to handle this case, please advise.

Thanks

thuy
Top achievements
Rank 1
 answered on 15 Nov 2017
9 answers
1.3K+ views
Hi,
    I am yogesh. I am new to asp.net with c# and working on telerik asp.netajax radgrid control. i want to select a row from radgrid and need to display values of row in textboxes which are in the same page.Could anyone help me out plz...
Anil
Top achievements
Rank 1
 answered on 14 Nov 2017
0 answers
198 views

Hi there, 

 

I'm having a problem with my radrid multi-level grouping.

When a Ajax request occours my grid loses all data.

 

I show my source code.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/IAMS.Master" AutoEventWireup="true" CodeBehind="ForeCastManager.aspx.cs" Inherits="LCG.Web.IAMS.AWA.Pages.ForeCastManager" %>
 
<%@ Register Src="~/Controls/Common/CustomNotification.ascx" TagPrefix="common" TagName="notification" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadAjaxManager ID="ForecastAjaxManager" runat="server">
        <AjaxSettings>
 
            <telerik:AjaxSetting AjaxControlID="ForecastClientesRadGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="TabForecastList" />
                    <telerik:AjaxUpdatedControl ControlID="ForecastPagesViews" LoadingPanelID="TaskLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ForecastPagesViews">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="TabForecastList" />
                    <telerik:AjaxUpdatedControl ControlID="ForecastPagesViews" LoadingPanelID="TaskLoadingPanel" />
 
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="TabForecastList">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="TabForecastList" />
                    <telerik:AjaxUpdatedControl ControlID="ForecastPagesViews" LoadingPanelID="TaskLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ForecastAjaxManager">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ForecastPagesViews" LoadingPanelID="TaskLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="TabForecastList" />
                    <telerik:AjaxUpdatedControl ControlID="ForecastClientesRadGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="TaskLoadingPanel">
    </telerik:RadAjaxLoadingPanel>
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <telerik:RadMenu runat="server" ID="MainMenu" RenderMode="Auto" EnableRoundedCorners="True" Width="100%"
        OnClientItemClicking="onMainMenuItemClicking" meta:resourcekey="RadMenu4Resource1" Style="z-index: 1">
        <Items>
            <telerik:RadMenuItem runat="server" Text="Create New" NavigateUrl="#CreateDocumentManagerAccount" meta:resourcekey="CreateDocumentManagerAccount">
            </telerik:RadMenuItem>
            <!-- when i click in "Create New" button a AjaxManager_request occours and i lost my grid information -->
                 
            <telerik:RadMenuItem runat="server" Text="Delete" NavigateUrl="#DeleteDocumentManagerAccount" meta:resourcekey="DeleteDocumentManagerAccount">
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>
    <telerik:RadTabStrip ID="TabForecastList" runat="server"
        MultiPageID="ForecastPagesViews"
        Orientation="HorizontalTop"
        OnClientLoad="OnClientLoad"
        SelectedIndex="0">
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="ForecastPagesViews" runat="server" OnPageViewCreated="ForecastPagesViews_PageViewCreated" Orientation="HorizontalTop" SelectedIndex="0" PerTabScrolling="true" RenderMode="Classic" ReorderTabsOnSelect="true">
        <telerik:RadPageView ID="DocumentClientsPageView" runat="server" Height="600px">
                <telerik:RadGrid
                    runat="server" ID="ForecastClientesRadGrid"
                    AutoGenerateColumns="False"
                    Height="600px"
                    BorderWidth="0px"
                    AllowSorting="True"
                    Style="outline: none"
                    EnableLinqExpressions="False"
                    OnItemCommand="ForecastClientesRadGrid_ItemCommand"
                    ShowGroupPanel="True"
                    FilterMenu-Enabled="true"
                    OnDetailTableDataBind="ForecastClientesRadGrid_DetailTableDataBind"
                    OnNeedDataSource="ForecastClientesRadGrid_NeedDataSource"
                    AllowPaging="True"
                    FilterType="Combined"
                    AllowFilteringByColumn="True"
                    AllowMultiRowEdit="True"
                    AllowAutomaticUpdates="True">
                    <ClientSettings
                        Scrolling-AllowScroll="True"
                        Scrolling-UseStaticHeaders="true"
                        Selecting-AllowRowSelect="true"
                        AllowGroupExpandCollapse="True"
                        AllowDragToGroup="true"
                        EnableRowHoverStyle="true">
                        <Selecting AllowRowSelect="True" />
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                        <ClientEvents OnRowDblClick="OnRowDblClick" />
                    </ClientSettings>
                    <PagerStyle Mode="NumericPages" PageSizeControlType="None"></PagerStyle>
                    <MasterTableView TableLayout="Fixed" PageSize="16" Width="100%" ClientDataKeyNames="ID" DataKeyNames="Id">
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="Id" Name="Forecast" Width="100%" AllowFilteringByColumn="false">
                                <Columns>
                                    <telerik:GridButtonColumn
                                        CommandName="RowClick"
                                        ImageUrl="../Images/edit.png" ButtonType="ImageButton"
                                        ItemStyle-HorizontalAlign="Center" ItemStyle-Width="30px" HeaderStyle-Width="30px"
                                        UniqueName="imageSingleClick">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" SortExpression="Id" UniqueName="Id" Display="false">
                                        <ColumnValidationSettings>
                                            <ModelErrorMessage Text="" />
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" AllowFiltering="false" UniqueName="Description">
                                        <ColumnValidationSettings>
                                            <ModelErrorMessage Text="" />
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        <Columns>
                            <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" FilterControlAltText="Filter Id column" HeaderText="Id" SortExpression="Id" UniqueName="Id" Display="false">
                                <ColumnValidationSettings>
                                    <ModelErrorMessage Text="" />
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter NIF column" HeaderText="Name" SortExpression="Name" UniqueName="Name" HeaderButtonType="TextButton">
                                <ColumnValidationSettings>
                                    <ModelErrorMessage Text="" />
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                        </Columns>
                        <PagerStyle PageSizeControlType="None" />
                    </MasterTableView>
                    <FilterMenu CssClass="RadFilterMenu_CheckList">
                    </FilterMenu>
                </telerik:RadGrid>
        </telerik:RadPageView>
    </telerik:RadMultiPage>
 
    <telerik:RadScriptBlock runat="server">
        <script type="text/javascript" src="../Scripts/pages/forecastManagerAccount.js"></script>
        <script type="text/javascript" src="../Scripts/lib/tabLib.js"></script>
        <script type="text/javascript">
            //<![CDATA[
            $(document).ready(function () {
                window.forecastManager = new Object();
                window.forecastManager.ajaxManager = $find("<%= ForecastAjaxManager.ClientID %>");
            });
 
 
            function OnRowDblClick(sender, args) {
                var index = args._itemIndexHierarchical;
                __doPostBack("<%= ForecastClientesRadGrid.UniqueID %>", "<%= this.CustomDoubleClickCommand %>" + ":" + index);
            }
 
            function onMainMenuItemClicking(sender, args) {
                mainMenuItemClicking(sender, args);
            }
 
            //]]>
        </script>
    </telerik:RadScriptBlock>
    <common:notification runat="server" ID="NotificationDialog" />
</asp:Content>

 

And respective code-behind

using LCG.Business.Entities.Contacts;
using LCG.Client.Contracts.Service;
using LCG.Client.Proxies.Proxies;
using LCG.Web.IAMS.AWA.Code;
using LCG.Web.IAMS.AWA.Controls.Documents;
using LCG.Web.IAMS.AWA.Controls.Forecast;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace LCG.Web.IAMS.AWA.Pages
{
    public partial class ForeCastManager : System.Web.UI.Page
    {
        ServiceFactory factory = new ServiceFactory();
        private SessionClientCredentials _credentials;
        private SessionClientCredentials credentials
        {
            get
            {
                if (_credentials == null)
                    _credentials = SessionCredentials.GetCurrentUser();
 
                return _credentials;
            }
        }
        public static string PageUrl = System.Web.VirtualPathUtility.ToAbsolute("~/Pages/ForeCastManager.aspx");
        private static string _moduleName = "Forecast";
        public string CustomDoubleClickCommand
        {
            get
            {
                return "CustomRowDoubleClick";
            }
        }
        public int TabIndex
        {
            get
            {
                return (int?)Session["tabIndex"] ?? TabForecastList.Tabs.Count;
            }
            set
            {
                Session["tabIndex"] = value;
            }
        }
 
        #region Page events
        protected void Page_Init(object sender, EventArgs e)
        {
 
            if (!Page.IsPostBack)
            {
                TabForecastList.Tabs.Add(new RadTab() { Text = _moduleName });
                TabIndex = 1;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ForecastAjaxManager.AjaxRequest += ForecastAjaxManager_AjaxRequest;
            var tabTemplate = new TabTemplate();
            foreach (RadTab tab in TabForecastList.Tabs)
            {
                if (!tab.Text.Equals(_moduleName, StringComparison.InvariantCultureIgnoreCase))
                {
                    tabTemplate.InstantiateIn(tab, _moduleName);
                }
            }
 
            if (!IsPostBack)
            {
                //TODO:Alterar isto para resources
                Page.Title = "IAMS - Forecast";
                RadSkinManager skinManager = new RadSkinManager();
                if (HttpContext.Current.Session["cultureId"] != null)
                {
                    string cultureId = (string)HttpContext.Current.Session["cultureId"];
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureId);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureId);
                }
            }
        }
        private void AddTab(string title, string id)
        {
            var tabTemplate = new TabTemplate();
            RadTab tab = new RadTab() { Text = title };
            tab.PostBack = false;
 
            tabTemplate.InstantiateIn(tab, _moduleName);
            TabForecastList.Tabs.Insert(TabForecastList.Tabs.Count, tab);
            TabForecastList.DataBind();
            TabForecastList.SelectedIndex = tab.Index;
        }
        private void AddPageView(bool isNew, string pvId)
        {
            try
            {
                RadPageView pageView = new RadPageView();
 
                if (isNew)
                {
                    pageView.ID = "NewForecast" + pvId;
                    //TabIndex++;
                }
                else
                {
                    pageView.ID = pvId;
                }
 
                pageView.CssClass = "pageView";
                ForecastPagesViews.PageViews.Add(pageView);
                ForecastPagesViews.SelectedIndex = pageView.Index;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void ForecastAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            string argument = e.Argument.ToLower();
            string[] strCommand = argument.Split('|');
 
            if (strCommand != null)
            {
                switch (strCommand[0])
                {
                    case "createdocumentmanageraccount":
                        TabIndex++;
                        AddTab("NewForecast", TabIndex.ToString());
                        AddPageView(true, TabIndex.ToString());
                        break;
 
                    case "savedocument":
                        ForecastInfo forecastInfo = FindFileTreeInfoControl(ForecastPagesViews.SelectedPageView.ID);
                        if (forecastInfo == null)
                        {
                            forecastInfo = FindFileTreeInfoControl(string.Format("NewForecast{0}", TabIndex));
                        }
                        forecastInfo.Save();
 
                        break;
                    default:
                        break;
                }
            }
        }
        private ForecastInfo FindFileTreeInfoControl(string id)
        {
            Control foundControl = ForecastPagesViews.SelectedPageView.FindControl(id);
            if (foundControl == null || foundControl.Controls == null || foundControl.Controls.Count == 0)
            {
                NotificationDialog.Show("Error", "An error occured getting the document.", TypeOfNotifications.Warning);
            }
 
            return (ForecastInfo)foundControl.Controls[0];
        }
 
        #endregion
        protected void ForecastPagesViews_PageViewCreated(object sender, Telerik.Web.UI.RadMultiPageEventArgs e)
        {
            if (e.PageView.ID.Contains("NewForecast"))
            {
                e.PageView.Controls.Add(LoadDocumentInfo(0));
            }
            else
            {
                e.PageView.Controls.Add(LoadDocumentInfo(int.Parse(e.PageView.ID)));
            }
        }
 
        private Control LoadDocumentInfo(int forecastId)
        {
            ForecastInfo forecastInfo = (ForecastInfo)Page.LoadControl("~/Controls/Forecast/ForecastInfo.ascx");
            var proxyCompany = factory.CreateClient<IContactService>(credentials, false);
 
            forecastInfo.SaveForecast += ForecastInfo_SaveForecast;
 
            if (forecastId == 0)
            {
                forecastInfo.Forecast = new Forecast();
                forecastInfo.ID = string.Format("ForecastInfonewForecast{0}", TabIndex);
            }
            else
            {
                Forecast forecast = new Forecast();
                forecast.Id = forecastId;
                forecast = proxyCompany.GetForecastById(forecast);
                #region EDIT
                proxyCompany.OpenChannel();
                forecastInfo.Forecast = forecast;
                //TODO: alterar isto
                forecastInfo.Companies = proxyCompany.GetCompanies(credentials.Account, credentials.User, 100, "").ToList();
                forecastInfo.Description = forecast.Description;
                forecastInfo.LoadForeCast();
                proxyCompany.CloseChannel();
                #endregion
 
            }
 
            return forecastInfo;
        }
 
        private void ForecastInfo_SaveForecast(Forecast forecast, EventArgs e)
        {
            var proxy = factory.CreateClient<IContactService>(credentials, false);
            try
            {
                proxy.OpenChannel();
 
                Forecast newForecast = proxy.GetForecastById(forecast);
 
                if (newForecast == null)
                {
                    newForecast = new Forecast();
                }
                newForecast.Description = forecast.Description;
                newForecast.CompanyId = forecast.CompanyId;
                newForecast.Id = forecast.Id;
                newForecast.Records = forecast.Records;
                if (forecast.Id != 0)
                {
                    proxy.UpdateForecast(forecast);
                }
                else
                {
                    proxy.CreateForecast(forecast);
                }
                TabForecastList.SelectedTab.Text = newForecast.Description;
                Label lbl = (Label)TabForecastList.SelectedTab.FindControl("lblTabTitle");
                lbl.Text = newForecast.Description;
                ForecastClientesRadGrid.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                proxy.CloseChannel();
            }
        }
 
        protected void ForecastClientesRadGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "RowClick")
            {
 
                GridEditableItem editedItem = e.Item as GridEditableItem;
                Hashtable newValues = new Hashtable();
                e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
                int entityId = newValues["Id"] != null ? Convert.ToInt32(newValues["Id"]) : 0;
                string title = newValues["Description"].ToString().Length > 20 ? string.Format("{0}...", newValues["Description"].ToString().Substring(0, 20)) : newValues["Description"].ToString();
                string eventArgument = string.Format("{0}:{1}:{2}", e.CommandName, entityId, title);
                OpenTab(eventArgument);
 
            }
        }
 
        protected void ForecastClientesRadGrid_DetailTableDataBind(object sender, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            var proxyForecast = factory.CreateClient<IContactService>(credentials);
            switch (e.DetailTableView.Name)
            {
                //1º
                case "Forecast":
                    {
                        string CompanyId = dataItem.GetDataKeyValue("Id").ToString();
                        e.DetailTableView.DataSource = proxyForecast.GetForeCastsByCompany(CompanyId).ToList();
                        break;
                    }
            }
        }
 
        protected void ForecastClientesRadGrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (!e.IsFromDetailTable)
            {
                var proxy = factory.CreateClient<IContactService>(credentials);
                List<Company> lstCompanies = new List<Company>();
                lstCompanies.AddRange(proxy.GetAllCompanies(credentials.Account, credentials.User).ToList());
                ForecastClientesRadGrid.DataSource = lstCompanies;
            }
        }
 
        private void OpenTab(string eventArgument)
        {
            string[] command = eventArgument.Split(':');
            string taskId = string.Empty;
            string title = string.Empty;
 
            switch (command[0])
            {
                case "CustomRowDoubleClick":
                    GridDataItem dataItem = (GridDataItem)ForecastClientesRadGrid.SelectedItems[0];
                    if (command.Length == 6 || (command.Length == 3 && dataItem["AbbreviatedName"].Text.Contains("DM#")))
                    {
                        taskId = dataItem["Id"].Text;
                        title = dataItem["Description"].Text;
                        title = (title.Length > 20 ? title.Substring(0, 20) + "..." : title);
                    }
                    break;
                case "RowClick":
 
                    taskId = command[1];
                    title = command[2];
                    break;
 
                default:
                    break;
            }
 
            if (!string.IsNullOrEmpty(taskId))
            {
                if (TabForecastList.FindTabByText(title) == null)
                {
                    AddTab(title, taskId);
                    AddPageView(false, taskId);
                }
                else
                {
                    TabForecastList.FindTabByText(title).Selected = true;
                    ForecastPagesViews.PageViews[TabForecastList.FindTabByText(title).Index].Selected = true;
                }
            }
 
        }
    }
}

 

Someone can help me?

 

Best regards,

 

 

 

tiago
Top achievements
Rank 1
 asked on 14 Nov 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?