Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
385 views
Hello,

If you select an item in RadMultiSelect, all server events works (OnSelectionChanged, OnItemSelected). If you deselect the same item, the events are not triggered (OnSelectionChanged, OnItemDeselected).
Then If you select the item again, it is triggered again.
Same works with deselecting. If you start with deselecting the item, events are triggered, if you select it again, they are not.
My RadMultiSelect is bound to RadAjaxManagerProxy, the events are noticed, there is loading animation for a while, but triggers are not working.

You can replicate this bug on your demo here:
https://demos.telerik.com/aspnet-ajax/multiselect/serversideevents/defaultcs.aspx
Peter Milchev
Telerik team
 answered on 09 Apr 2020
4 answers
117 views
i have this issue  that i just got what is causing in and it is the rad window..and what is annoting is that it doesnt happen evey time ..i have a rad grid with 1 column as command column when clicked a radwindow will apear using this code
Dim window1 As New Telerik.Web.UI.RadWindow 
            window1.Modal = True 
            window1.Title = "Assign Team" 
            window1.VisibleTitlebar = True 
 
            window1.Width = 500 
            window1.Height = 500 
            window1.DestroyOnClose = True 
            window1.NavigateUrl = "~/assign_team_mod.aspx" 
            windowmanager.Windows.Add(window1) 
          
            window1.VisibleOnPageLoad = True 

when i just close the window i press edit or do anything in my page that causes a postback opperation i get the following error!!
sys.webforms.pagerequestmanagerservererrorexception: failed to load viewstate.  the control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. for example when adding the controls dynamically, the controls added during the post-back must match the type and position of the controls added during the initial reques 

i posted this problem in the grid forum but i just realised that the cause was closing the window so..any idea of what am i doing wrong?
Kris
Top achievements
Rank 2
 answered on 07 Apr 2020
2 answers
127 views

My users need to copy and paste a link to their file that we would like to use fileexplorer to manage.

Is there an event where this could be shown perhaps outside of the control , or in the path bar?

 

Example:

Path bar currently shows user  "/MyFiles/"  when "My Picture.jpg" is selected

I would like to show  "https://www.foo.com/abx345/MyFiles/My%20Picture.jpg" somewhere on the page.  It doesn't matter if it is inside the control or outside.

 

Thanks.

 

Vessy
Telerik team
 answered on 07 Apr 2020
3 answers
222 views
Hi, I would like to include a GridButtonColumn in my grid which, when clicked, it would reset some fields of my database from code behind.  However, I would like to show the user a RadConfirm window such as the one that appears when you press the delete icon in the delete button column, that asks the user if he/she is sure that he wants to execute such reset.  If the user answers "no" or "cancel" then the code behind would not be executed.

Is there anyway I can do this or any tutorial or code library that I can use to accomplish this??

Thanks in advance,
Manuel
Dave
Top achievements
Rank 1
 answered on 07 Apr 2020
8 answers
591 views
I am using the IMage gallery successfully except for a few images which are higher than they are wide, and when rendered in the control, it rotates them sideways. I want to prevent this without modifying the image. How can I get the control to display the image
Peter Milchev
Telerik team
 answered on 07 Apr 2020
6 answers
1.8K+ views

I've been working with an application using a fairly old version of Telerik (2012.3.1205.40 , looks like) and I've been looking for a way to modify the style of the column headers in exported Excel files made from a RadGrid.  I've tried to attack this a number of ways, but the ExportCellFormatting event and related don't seem to cover the column headers, and attempting to manipulate the HeaderStyle of the RadGrid/the MasterTableView has also had no effect on how the exported column headers look.  I've had no problems styling the actual data fields, just the headers.  I'm sure I'm missing something very obvious to do this, but haven't found anything clear to point me at it in various searches online and looking through documentation/the API.

The function firing off the export is straightforward:

protected void lnkExportExcel_Click(object sender, EventArgs e)
{
    radgridResult.ExportSettings.ExportOnlyData = true;
    radgridResult.ExportSettings.OpenInNewWindow = true;
    radgridResult.ExportSettings.IgnorePaging = true;
...
    radgridResult.MasterTableView.ExportToExcel();
}

The omitted piece is just some wrangling of the exported file's name and shouldn't matter.

TIA!
Evan
Top achievements
Rank 1
 answered on 07 Apr 2020
3 answers
119 views
I’m loading stuff into the RadFileExplorer with both JavaScript and server-side code. My problem is sometime things are not visible until I resize my browsers window. So, some code that I want is fired upon the windows resize, I want to fire that code manually. So, my question is, what JavaScript code is being fired when I resize the window for the RadFileExplorer?
Vessy
Telerik team
 answered on 07 Apr 2020
2 answers
277 views

When doing a copy / paste of numeric values from excel to RadSpreadsheet initial zero values are lost. So, when I copy for example value 07657656 it gets pasted as 7657656.

Is there any workaround this behavior?

Giorgos
Top achievements
Rank 1
 answered on 03 Apr 2020
8 answers
141 views

In our application we use a RadEditor with

this.EditModes = EditModes.All

 

and

this.NewLineMode = EditorNewLineModes.P

 

so that the user can write text that is then translated into a paragraph html element. 

We also use this code for formatting options

this.StripFormattingOptions = EditorStripFormattingOptions.MSWordRemoveAll
                        | EditorStripFormattingOptions.ConvertWordLists
                        | EditorStripFormattingOptions.Span;

 

The Problem: For some reason our RadEditor is allowing the user to backspace so far that the <p> element for the NewLineMode actually gets deleted and removed, and the following text that is entered by the user is no longer translated into the paragraph html we need from the html mode. Does anyone know why this might be happening to the RadEditor? Perhaps we have some scripts/styles that are crossing the functionality but I have done a pretty thorough read through and figured it would be worth asking to see if anyone has an idea off the top of their head.

Any help is much appreciated and thank you.

 

Dave

Rumen
Telerik team
 answered on 03 Apr 2020
1 answer
223 views

Is there any way to get current rows  from RadGrid on Server side, because I want to call some method end set some of the fields only for currently showed rows. I'm using OnNeedDataSource and i have grouping and sorting in my RadGrid. 

For better understanding here is example:

I have 1000 elements in database and i want my method to apply only on items that i'm showing (10/20/50) one current page of paggination. 

<div class="demo-container no-bg">
                <telerik:RadGrid runat="server"
                    ID="OrdiniDashboard_Grid"
                    OnNeedDataSource="OnNeedDataSource_OrdiniDashboard"
                    RenderMode="Lightweight"
                    PageSize="10"
                    AllowSorting="True"
                    AllowMultiRowSelection="True"
                    AllowPaging="True"
                    ShowGroupPanel="True"
                    AutoGenerateColumns="False"
                    OnPreRender="GridOrdDashboard_PreRender"
                    OnItemCreated = "OnItemCreated">
                    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" Position="Bottom"></PagerStyle>
                    <MasterTableView
                        Width="100%"
                        GroupLoadMode="Client"
                        ShowGroupFooter="true"
                        ClientDataKeyNames="IdOrder, IdCliente,TipologiaCliente,RagSoc,NomeU,CognomeU,Confirm,PriorityId,PriorityCompleteName,FlagPagamento,StatoPagamento, OrdineEsportato, OrdineEsportatoName, totaleImporto,totaleValue">
                        <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                                <SelectFields>
                                    <telerik:GridGroupByField
                                        FieldAlias="DataScadenza"
                                        FieldName="DataScadenza"
                                        HeaderText="<%$ Resources: Doc_Labels, dataScadenza %>"
                                        FormatString="{0:dd/MM/yyyy}"
                                        HeaderValueSeparator="from date: "></telerik:GridGroupByField>
                                </SelectFields>
                                <GroupByFields>
                                    <telerik:GridGroupByField
                                        FieldName="DataScadenza"></telerik:GridGroupByField>
                                </GroupByFields>
                            </telerik:GridGroupByExpression>
                            <telerik:GridGroupByExpression>
                                <SelectFields>
                                    <telerik:GridGroupByField
                                        FieldAlias="StatoOrdineValue"
                                        FieldName="StatoOrdineValue"
                                        HeaderText="Stato"></telerik:GridGroupByField>
                                </SelectFields>
                                <GroupByFields>
                                    <telerik:GridGroupByField
                                        FieldName="StatoOrdineValue"></telerik:GridGroupByField>
                                </GroupByFields>
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>

                        <Columns>

                        <telerik:GridBoundColumn
                                AutoPostBackOnFilter="false"
                                DataField="IdOrder"
                                DataType="System.Int32"
                                UniqueName="IdOrder"
                                Display="false"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center">
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn
                                AutoPostBackOnFilter="false"
                                DataField="IdCliente"
                                DataType="System.Int32"
                                UniqueName="IdCliente"
                                Display="false"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center">
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn
                                AutoPostBackOnFilter="false"
                                SortExpression="NumeroOrdine"
                                Groupable="false"
                                HeaderText=" <%$ Resources: Doc_Labels, numero %>"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                DataField="NumeroOrdine"
                                Display="true"
                                Aggregate="Count"
                                FooterAggregateFormatString="Ordini totali: {0}"
                                UniqueName="NumeroOrdine">
                            </telerik:GridBoundColumn> 

                            <telerik:GridBoundColumn AutoPostBackOnFilter="false"
                                SortExpression="JobName"
                                Groupable="false"
                                DataField="JobName"
                                Display="true"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText=" <%$ Resources: Doc_Labels, jobName %>">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn
                                AutoPostBackOnFilter="false"
                                SortExpression="Cliente"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                UniqueName="Cliente"
                                DataField="Cliente"
                                GroupByExpression="Cliente Group By Cliente"
                                Groupable="true"
                                HeaderText=" <%$ Resources: Doc_Labels, cliente %>">
                                <ItemTemplate>
                                    <a href="../../../Views/settings/Clienti/Gestione_Cliente.aspx?idCliente="></a>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn
                                UniqueName="DataOrdine"
                                AutoPostBackOnFilter="false"
                                SortExpression="DataOrdine"
                                HeaderText=" <%$ Resources: Doc_Labels, dataEmissione %>"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderButtonType="TextButton"
                                DataField="DataOrdine"
                                GroupByExpression="DataOrdine Group By DataOrdine"
                                Groupable="true"
                                DataFormatString="{0:dd/MM/yyyy}"
                                Display="true">
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn
                                AutoPostBackOnFilter="false"
                                SortExpression="DataScadenza"
                                HeaderText=" <%$ Resources: Doc_Labels, dataScadenza %>"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderButtonType="TextButton"
                                DataField="DataScadenza"
                                DataFormatString="{0:dd/MM/yyyy}"
                                Display="true">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn
                                AutoPostBackOnFilter="false"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                UniqueName="Confirm"
                                SortExpression="StatoOrdineValue"
                                HeaderButtonType="TextButton"
                                GroupByExpression="StatoOrdineValue Group By StatoOrdineValue"
                                HeaderText=" <%$ Resources: Doc_Labels, stato %>"
                                DataField="StatoOrdineValue"
                                DataType="System.String">
                                <ItemTemplate>
                                    <div></div>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridTemplateColumn
                                UniqueName="Priority"
                                HeaderText="Priority"
                                SortExpression="PriorityCompleteName"
                                DataType="System.String"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                DataField="PriorityCompleteName"
                                GroupByExpression="PriorityCompleteName Group By PriorityCompleteName">
                                <ItemTemplate>
                                    <span class="label label-sm circle popovers infoPopOver"
                                        style="color: white; background-color: rgb(132, 151, 152);"
                                        data-placement="top"
                                        data-trigger="hover"></span>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn
                                UniqueName="StatoDocumentoFattura"
                                DataField="StatoDocumentoFattura"
                                SortExpression="StatoDocumentoFattura"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText=" <%$ Resources: Doc_Labels, gestioneStatoDocumento %>"
                                GroupByExpression="StatoDocumentoFattura Group By StatoDocumentoFattura">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn
                                UniqueName="StatoPagamento"
                                SortExpression="StatoPagamento"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText="<%$ Resources:Doc_Labels, statoPagamento %>"
                                HeaderStyle-HorizontalAlign="Center"
                                GroupByExpression="StatoPagamento Group By StatoPagamento"
                                DataField="StatoPagamento">
                                <ItemTemplate>
                                    <i class="fa fa-euro popovers"
                                        data-placement="top"
                                        data-trigger="hover"
                                        style="width: 100%"></i>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn
                                UniqueName="TipoPagamento"
                                DataField="TipoPagamento"
                                SortExpression="TipoPagamento"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText=" <%$ Resources: Doc_Labels, tipoPagamento %>"
                                GroupByExpression="TipoPagamento Group By TipoPagamento">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn
                                UniqueName="OrdineEsportato"
                                DataField="OrdineEsportato"
                                SortExpression="OrdineEsportato"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText=" <%$ Resources: Doc_Labels, esportato %>"
                                GroupByExpression="OrdineEsportatoName Group By OrdineEsportatoName">
                                <ItemTemplate>
                                    <i class=" fa fa-check-circle  popovers infoPopOver"
                                        data-placement="top"
                                        data-trigger="hover"
                                        style="width: 2%"></i>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn
                                UniqueName="DataEsportazioneOrdine"
                                DataField="DataEsportazioneOrdine"
                                SortExpression="DataEsportazioneOrdine"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText="Data Esportazione Ordine"
                                DataFormatString="{0:dd/MM/yyyy}"
                                GroupByExpression="DataEsportazioneOrdine Group By DataEsportazioneOrdine">
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn
                                UniqueName="Autore"
                                DataField="Autore"
                                SortExpression="Autore"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                HeaderText=" <%$ Resources: Doc_Labels, autore %>"
                                GroupByExpression="Autore Group By Autore">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn
                                AutoPostBackOnFilter="false"
                                DataType="System.Decimal"
                                UniqueName="totaleImporto"
                                Display="true"
                                Aggregate="Sum"
                                FooterAggregateFormatString="Imponibile: {0:C}"
                                HeaderText="<%$ Resources: Doc_Labels, imponibile %>"
                                DataField="totaleImporto"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                Groupable="false">
                            </telerik:GridTemplateColumn>

                            <telerik:GridTemplateColumn
                                AutoPostBackOnFilter="false"
                                DataType="System.Decimal"
                                UniqueName="totaleValue"
                                Display="true"
                                Aggregate="Sum"
                                FooterAggregateFormatString="Totali: {0:C}"
                                HeaderText="<%$ Resources: Doc_Labels, totali %>"
                                DataField="totaleValue"
                                HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-VerticalAlign="Middle"
                                ItemStyle-HorizontalAlign="Center"
                                Groupable="false">
                                <ItemTemplate>
                                    <div>
                                    </div>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                    <ClientSettings
                        ReorderColumnsOnClient="True"
                        AllowDragToGroup="True"
                        AllowColumnsReorder="True">
                        <ClientEvents
                            OnGroupExpanded="OrdDashboard_OnGroupExpandedCollapse"
                            OnGroupCollapsed="OrdDashboard_OnGroupExpandedCollapse"
                            OnRowCreated="OnRowDataBoundOrdini"
                            OnCommand="OnCommadFunction"></ClientEvents>
                        <Selecting AllowRowSelect="True" />
                        <Resizing
                            AllowRowResize="False"
                            AllowColumnResize="False"
                            EnableRealTimeResize="False"
                            ResizeGridOnColumnResize="False"></Resizing>
                    </ClientSettings>
                    <GroupingSettings ShowUnGroupButton="true" RetainGroupFootersVisibility="false" />
                </telerik:RadGrid>
            </div>

 

        public ResultData GetOrdiniListForDashboard(string filterExpression)
        {
            var result = new ResultData();
            MyRigaPrev rigaPrev = new MyRigaPrev();
            DocNewReport_footer_ord_prev_Result my;
            DALDocumentale db = new DALDocumentale(0);          // Database
            try
            {
                //IQueryable<MyOrdDashboard> list = null;
                var list = (from ord in db.Ordini
                            where (ord.TipologiaDocumento == null || ord.TipologiaDocumento == "order" && ord.IdOrder > 0)
                            join prioritySetts in db.Priority on ord.PriorityId equals prioritySetts.Id
                            into priority
                            from p in priority.DefaultIfEmpty()
                            select new MyOrdDashboard
                            {
                                IdOrder = ord.IdOrder ?? 0,
                                IdCliente = ord.IdCliente ?? 0,
                                TipologiaCliente = ord.TipologiaCliente ?? 0,
                                RagSoc = ord.RagSoc ?? "",
                                NomeU = ord.NomeU ?? "",
                                CognomeU = ord.CognomeU ?? "",
                                PriorityId = ord.PriorityId ?? 0,
                                NumeroOrdine = ord.NumeroOrdine ?? "",
                                JobName = ord.JobName ?? "",
                                DataOrdine = ord.DataOrdine,
                                DataScadenza = ord.DataScadenza,
                                Confirm = ord.Confirm ?? 0,
                                //PriorityName = p != null && !string.IsNullOrEmpty(p.Name) ? p.Name[0] : 'N',
                                PriorityCompleteName = p.Name ?? "Nessuna",
                                //StatoOrdine = ord.Confirm ?? 0,                                                                 // State of ordine:
                                StatoOrdineValue = ord.Confirm == 1 ? "In Coda" :                                                                    // 1 -- InCoda
                                                  (ord.Confirm == 2 ? "In Lavorazione" :                                                             // 2 -- InLavorazione
                                                  (ord.Confirm == 3 ? "Evaso" : "Annullato")),                                                       // 3 -- Evaso
                                                                                                                                                     // 4 -- Annullato
                                Cliente = ord.TipologiaCliente == 5 || ord.TipologiaCliente == 6 ? ord.RagSoc : ord.NomeU + " " + ord.CognomeU,      // Type of client: 
                                                                                                                                                     // private: NomeU + CognomeU
                                                                                                                                                     // company: RagSoc
                                StatoDocumentoFattura = ord.StatoDocumentoFattura == "fatturatoParziale" ? Resources.Doc_Labels.fatturatoParziale :
                                                        (ord.StatoDocumentoFattura == "fatturato" ? Resources.Doc_Labels.fatturato :
                                                        (ord.StatoDocumentoFattura == "nonFatturabile" ? Resources.Doc_Labels.nonFatturabile :
                                                        (ord.StatoDocumentoFattura == "daFatturare" ? Resources.Doc_Labels.daFatturare :
                                                        (ord.StatoDocumentoFattura == "" || ord.StatoDocumentoFattura == null ? Resources.Doc_Labels.daFatturare : "")))),


                                StatoGatewayTransazione = ord.StatoGatewayTransazione ?? 0,
                                StatoPagamento = ord.StatoGatewayTransazione == 0 ? Resources.Doc_Labels.nonEseguito : Resources.Doc_Labels.eseguito,
                                FlagPagamento = ord.StatoGatewayTransazione ?? 0,
                                IdGateway = ord.IdGateway ?? 0,
                                TipoPagamento = ord.TipologiaPagamento ?? Resources.Doc_Labels.nessuno,
                                OrdineEsportato = ord.OrdineEsportato ?? false,
                                OrdineEsportatoName = ord.OrdineEsportato != null ? Resources.Doc_Labels.esportato : Resources.Doc_Labels.nonesportato,
                                DataEsportazioneOrdine = ord.DataEsportazioneOrdine,
                                Autore = ord.EmessoDa,
                                //totaleImporto = Convert.ToDecimal((rigaPrev.getTotali(Convert.ToInt32(ord.IdOrder), "ordine", "").Imponibile)),
                                //totaleValue = Convert.ToDecimal((rigaPrev.getTotali(Convert.ToInt32(ord.IdOrder), "ordine", "").Totale)),
                            });

                //IQueryable<MyOrdDashboard> ordini = null;

                //replace DateTime.Parse
                int countDate = Regex.Matches(filterExpression, "DateTime.Parse").Count;
                var listaDate = new object[countDate];

                if (countDate > 0)
                {
                    //for the DateTime expression to work we need to handle them as
                    filterExpression = filterExpression.Replace("DateTime.Parse", string.Empty);

                    for (int i = 0; i < countDate; i++)
                    {
                        //Create a new Regular expression that covers all the date types!
                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(
                            "\\(\\\"" +
                                "\\d{1,2}[/-]\\d{1,2}[/-]\\d{2,4}" + //mm/dd/yyyy
                                "(?:" +
                                    "\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}" + // hh:mm:ss
                                    "(?:" +
                                        "\\s*(?:AM|PM){0,2}" + // AM
                                    "){0,1}" +
                                "){0,1}" +
                            "\\\"\\)",
                            RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled
                            );

                        string date = regex.Match(filterExpression).ToString().Replace("\"", string.Empty).Replace("(", string.Empty).Replace(")", string.Empty);
                        DateTime d = Convert.ToDateTime(date);
                        filterExpression = regex.Replace(filterExpression, "@" + i.ToString(), 1);

                        listaDate[i] = d;
                    }
                }


                if (!String.IsNullOrEmpty(filterExpression))
                {
                    if (countDate > 0)
                    {
                        list = list.AsQueryable().Where(filterExpression, listaDate);
                    }
                    else
                    {
                        list = list.AsQueryable().Where(filterExpression);
                    }
                }



                result.Data = list.ToList();
                result.Count = list.Count();

            }
            catch (Exception e)
            {
                throw e;
            }

            return result;
        }



protected void OnNeedDataSource_OrdiniDashboard(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {

            DocNewGroupingTemplate docNewGroupingTemplate = new DocNewGroupingTemplate();
            docNewGroupingTemplate.GroupingTemplateDetailsList = new List<DocNewGroupingTemplateDetails>();
            ControllerGroupingTemplate ctrlGroupTemp = new ControllerGroupingTemplate();
            string sortExpression = String.Empty;

            Helper helper = new Helper();
            if (!helper.isValid(HttpContext.Current.Session))
            {
                return;
            }
            try
            {
                int groupingId = 0;
                if (HttpContext.Current.Session["GroupingTemplateComboBox"] != null)
                {
                    groupingId = Int32.Parse(HttpContext.Current.Session["GroupingTemplateComboBox"].ToString());
                    if(groupingId == -1)
                    {
                        docNewGroupingTemplate.GroupingName = "";
                        docNewGroupingTemplate.GroupingTemplateDetailsList = new List<DocNewGroupingTemplateDetails>();
                        docNewGroupingTemplate.GroupingTemplateDetailsList.Add(new DocNewGroupingTemplateDetails() { ColumnName = "DataScadenza", SortType = "Descending", GroupingSenderId = "dataScadenza", Type= "Data scadenza" });
                        docNewGroupingTemplate.GroupingTemplateDetailsList.Add(new DocNewGroupingTemplateDetails() { ColumnName = "StatoOrdineValue", SortType = "Descending", GroupingSenderId = "statoOrdineValue", Type = "Stato" });

                    }
                    else
                    {
                        docNewGroupingTemplate.GroupingName = ctrlGroupTemp.GetGroupingTemplateName(groupingId);
                        docNewGroupingTemplate.GroupingTemplateDetailsList = ctrlGroupTemp.GetGroupingTemplateDetailsList(groupingId);
                    }
                }

                string filterPeriod = HttpContext.Current.Session["FilterPeriod"].ToString();
                string filterExpression = String.Empty;

                if (filterPeriod != "Nessuno")
                {
                    string ricercaPerPeriodo = HttpContext.Current.Session["RicercaPerPeriodo"].ToString();
                    string fromDate = HttpContext.Current.Session["From"].ToString();
                    string toDate = HttpContext.Current.Session["To"].ToString();
                    DateTime currentDate = DateTime.Now;

                    if (ricercaPerPeriodo != "Personalizzato")
                    {
                        HttpContext.Current.Session.Add("From", String.Empty);
                        HttpContext.Current.Session.Add("To", String.Empty);
                        fromDate = String.Empty;
                        toDate = String.Empty;
                    }


                    if (!String.IsNullOrEmpty(filterPeriod) && !String.IsNullOrEmpty(ricercaPerPeriodo) && filterPeriod != "Nessuno")
                    {

                        switch (ricercaPerPeriodo)
                        {
                            case "Oggi":
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{currentDate.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{currentDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;
                            case "Ieri":
                                currentDate = DateTime.Now.AddDays(-1);
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{currentDate.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{currentDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;

                            case "QuestaSettimana":
                                DateTime monday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + 1);
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{monday.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{currentDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;

                            case "QuestoMese":
                                DateTime month = DateTime.Today.AddDays(-(int)DateTime.Today.Day + 1);
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{month.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{currentDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;

                            case "SettimanaScorsa":
                                DateTime mondayOfLastWeek = currentDate.AddDays(-(int)currentDate.DayOfWeek - 6);
                                DateTime sundayOfLastWeek = currentDate.AddDays(-(int)currentDate.DayOfWeek);
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{mondayOfLastWeek.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{sundayOfLastWeek.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;
                            case "MeseScorso":
                                DateTime lastMonth = new DateTime(currentDate.Year, currentDate.Month, 1);
                                DateTime first = lastMonth.AddMonths(-1);
                                DateTime last = lastMonth.AddDays(-1);
                                filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{first.Date}\")) AND ({filterPeriod} <= DateTime.Parse(\"{last.Date.AddHours(23).AddMinutes(59).AddSeconds(59)}\"))";
                                break;
                            case "Personalizzato":
                                if (!String.IsNullOrEmpty(fromDate) && !String.IsNullOrEmpty(toDate))
                                    filterExpression = $"({filterPeriod} >= DateTime.Parse(\"{fromDate}\")) AND ({filterPeriod} <= DateTime.Parse(\"{toDate}\"))";
                                break;

                            case "Nessuno":
                                filterExpression = String.Empty;
                                break;

                            default:
                                filterExpression = String.Empty;
                                break;
                        }
                    }
                }


                ResultData result = GetOrdiniListForDashboard(filterExpression);

                if (groupingId != 0)
                {

                    OrdiniDashboard_Grid.MasterTableView.GroupByExpressions.Clear();
                    foreach (var item in docNewGroupingTemplate.GroupingTemplateDetailsList)
                    {
                        GridGroupByField field = new GridGroupByField();
                        field.FieldName = item.ColumnName;
                        field.HeaderText = item.Type;
                        if (item.SortType == "Ascending")
                            field.SortOrder = GridSortOrder.Ascending;
                        else if (item.SortType == "Descending")
                            field.SortOrder = GridSortOrder.Descending;
                        else
                            field.SortOrder = GridSortOrder.None;
                        GridGroupByField selectfield = new GridGroupByField();
                        selectfield.FieldName = item.ColumnName;
                        selectfield.HeaderText = item.Type;
                        selectfield.FormatString = "{0:dd/MM/yyyy}";
                        GridGroupByExpression ex = new GridGroupByExpression();
                        ex.GroupByFields.Add(field);
                        ex.SelectFields.Add(selectfield);
                        OrdiniDashboard_Grid.MasterTableView.GroupByExpressions.Add(ex);
                        
                    }                  

                    HttpContext.Current.Session.Add("GroupingTemplateComboBox", 0);
                }

                if (result.Count > 0)
                {
                    OrdiniDashboard_Grid.DataSource = result.Data;

                    
                }
                else
                {
                    OrdiniDashboard_Grid.DataSource = new List<MyOrdDashboard>();
                }

            }
            catch (Exception exe)
            {
                throw exe;
            }
        }
Doncho
Telerik team
 answered on 03 Apr 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?