Blazor how to export pdf according to range of date like Date start to Date end

Hi i just wanted to export a pdf according to Date Started to Date End picker from data source of datagrid 

9 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team November 18, 2020 10:28 AM UTC

Hi Leonardo,  
 
Thanks for contacting Syncfusion support.  
 
Query: “i just wanted to export a pdf according to Date Started to Date End picker from data source of datagrid 
 
We have analyzed your query and Grid data can be exported to Pdf format using PdfExport() method of Grid. While exporting, grid will consider the data operations applied to its data (i.e.) if filtering is applied, filtered data will be exported. So we have filtered the Grid using DateRangePicker component value and export the Grid data on external button click.  
 
Refer the below code example.  
 
<SfDateRangePicker @ref="DatePicker" Placeholder="Choose a Range"> 
    <DateRangePickerEvents ValueChange="OnChange"></DateRangePickerEvents> 
</SfDateRangePicker> 
  
<SfButton OnClick="PdfExport" Content="Pdf Export"></SfButton> 
 
<SfGrid @ref="DefaultGrid" DataSource="@Orders" Query="@Qry" AllowPdfExport="true" AllowPaging="true"> 
</SfGrid> 
  
@code{ 
    private SfGrid<Order> DefaultGrid; 
    public Query Qry = new Query(); 
    SfDateRangePicker DatePicker { getset; } 
    public List<Order> Orders { getset; } 
    public void OnChange(RangeEventArgs Args) 
    { 
        var Col1Pre = new WhereFilter(); 
        var predicate = new List<WhereFilter>(); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderDate"value = Args.StartDate, Operator = "greaterthanorequal" }); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderDate"value = Args.EndDate, Operator = "lessthanorequal" }); 
        Col1Pre = WhereFilter.And(predicate); 
        Qry = new Query().Where(Col1Pre); // to filter the Grid  
    } 
    public async Task PdfExport() 
    { 
        await this.DefaultGrid.PdfExport(); // export the Grid to PDF format 
    } 
 
Kindly download the sample from below which we have prepared using above solution.  
 
 
Refer our Ug documentation for your reference 
 
 
Please get back to us if you have further queries.    
 
Regards, 
Vignesh Natarajan  
 


Marked as answer

LE leonardo November 20, 2020 04:14 AM UTC

Wow that was amazing! thank you so much


RN Rahul Narayanasamy Syncfusion Team November 23, 2020 05:48 AM UTC

Hi Leonardo, 

Thanks for the update. 

Please get back to us if you need further assistance. 

Regards, 
Rahul 



LE leonardo November 27, 2020 03:05 AM UTC

How about this one, how did you make this chat app that can have emoticons and store data in SQL Server.
sample screenshot from zip below.

Attachment: Untitled_6abda495.rar


VN Vignesh Natarajan Syncfusion Team November 27, 2020 12:46 PM UTC

Hi Leonardo,  
 
Query: “How about this one, how did you make this chat app that can have emoticons and store data in SQL Server 
 
We have analyzed your query and we suspect that you want to develop a chat similar to attached screenshot. It is a third party application which we have incorporated in our chat conversation and there are many third party applications available for this in the market. 
 
Please get back to us if you have further queries.    
 
Regards, 
Vignesh Natarajan 



LE leonardo replied to Vignesh Natarajan December 11, 2020 02:33 AM UTC

Hi Leonardo,  
 
Thanks for contacting Syncfusion support.  
 
Query: “i just wanted to export a pdf according to Date Started to Date End picker from data source of datagrid 
 
We have analyzed your query and Grid data can be exported to Pdf format using PdfExport() method of Grid. While exporting, grid will consider the data operations applied to its data (i.e.) if filtering is applied, filtered data will be exported. So we have filtered the Grid using DateRangePicker component value and export the Grid data on external button click.  
 
Refer the below code example.  
 
<SfDateRangePicker @ref="DatePicker" Placeholder="Choose a Range"> 
    <DateRangePickerEvents ValueChange="OnChange"></DateRangePickerEvents> 
</SfDateRangePicker> 
  
<SfButton OnClick="PdfExport" Content="Pdf Export"></SfButton> 
 
<SfGrid @ref="DefaultGrid" DataSource="@Orders" Query="@Qry" AllowPdfExport="true" AllowPaging="true"> 
</SfGrid> 
  
@code{ 
    private SfGrid<Order> DefaultGrid; 
    public Query Qry = new Query(); 
    SfDateRangePicker DatePicker { getset; } 
    public List<Order> Orders { getset; } 
    public void OnChange(RangeEventArgs Args) 
    { 
        var Col1Pre = new WhereFilter(); 
        var predicate = new List<WhereFilter>(); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderDate"value = Args.StartDate, Operator = "greaterthanorequal" }); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderDate"value = Args.EndDate, Operator = "lessthanorequal" }); 
        Col1Pre = WhereFilter.And(predicate); 
        Qry = new Query().Where(Col1Pre); // to filter the Grid  
    } 
    public async Task PdfExport() 
    { 
        await this.DefaultGrid.PdfExport(); // export the Grid to PDF format 
    } 
 
Kindly download the sample from below which we have prepared using above solution.  
 
 
Refer our Ug documentation for your reference 
 
 
Please get back to us if you have further queries.    
 
Regards, 
Vignesh Natarajan  
 


Hi i have problem when picking start date to end date

What if i have this data in SQL server and using EFCORE can you help me im stock in here.


Refer the below code example.

@inject IEmployeeService EmployeeService


<SfDateRangePicker @ref="DatePicker" Placeholder="Choose a Range">
                        <DateRangePickerEvents ValueChange="OnChange"></DateRangePickerEvents>
                    </SfDateRangePicker>
                    <SfButton OnClick="PdfExport" Content="Pdf Export"></SfButton>
                    <p>@OrderDate</p>

                    <SfGrid @ref="DefaultGrid" DataSource="@employeeList" Query="@Qry" AllowPdfExport="true" AllowPaging="true">
                        <GridColumns>
                            <GridColumn Field=@nameof(employee.SenderName) HeaderText="Sender Name" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                            <GridColumn Field=@nameof(employee.DocumentType) HeaderText="Document Type" Width="150"></GridColumn>
                            <GridColumn Field=@nameof(employee.Date) HeaderText="Date Routed" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
                            <GridColumn Field=@nameof(employee.Remarks) HeaderText="Remarks" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                        </GridColumns>
                    </SfGrid>


@code{
          Employee employee = new Employee();
          List<Employee> employeeList;

          private SfGrid<Employee> DefaultGrid;
           public Query Qry = new Query();
          SfDateRangePicker DatePicker { get; set; }

protected override async Task OnInitializedAsync()
    {
          employeeList = await EmployeeService.GetEmployees();
     }


          public void OnChange(RangeEventArgs Args)
    {
        var Col1Pre = new WhereFilter();
        var predicate = new List<WhereFilter>();
        predicate.Add(new WhereFilter() { Condition = "or", Field = "Date", value = Args.StartDate, Operator = "greaterthanorequal" });
        predicate.Add(new WhereFilter() { Condition = "or", Field = "Date", value = Args.EndDate, Operator = "lessthanorequal" });
        Col1Pre = WhereFilter.And(predicate);
        Qry = new Query().Where(Col1Pre); // to filter the Grid
    }
}




VN Vignesh Natarajan Syncfusion Team December 11, 2020 11:39 AM UTC

Hi Leonardo,  

Query: “ i have problem when picking start date to end date What if i have this data in SQL server and using EFCORE can you help me im stock in here. 

As we are quite unclear about the issue, we need some more information about the issue you are facing. So kindly share the following details.  

  1. Are you facing issue while selecting a value in DataRangePicker
  2. Or facing trouble while filtering the Grid data using the Query property.
  3. Share the screenshot of the script error / exception if you are facing any.
  4. Share the video demonstration of the issue along with replication procedure.
  5. Share more details about the issue.

Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible.  

Regards, 
Vignesh Natarajan 



LE leonardo replied to Vignesh Natarajan December 14, 2020 12:48 AM UTC

Hi Leonardo,  

Query: “ i have problem when picking start date to end date What if i have this data in SQL server and using EFCORE can you help me im stock in here. 

As we are quite unclear about the issue, we need some more information about the issue you are facing. So kindly share the following details.  

  1. Are you facing issue while selecting a value in DataRangePicker
  2. Or facing trouble while filtering the Grid data using the Query property.
  3. Share the screenshot of the script error / exception if you are facing any.
  4. Share the video demonstration of the issue along with replication procedure.
  5. Share more details about the issue.

Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible.  

Regards, 
Vignesh Natarajan 


Hi i am facing trouble while filtering the Grid data using the Query property.
I have this data set from SQL server "employee.Date" and tried to run with no errors but doesn't search all the desired date pick
my sample code below. 

public void OnChange(RangeEventArgs Args)
    {
        var Col1Pre = new WhereFilter();
        var predicate = new List<WhereFilter>();
        predicate.Add(new WhereFilter() { Condition = "or", Field = employee.Date.ToString("dd/MM/yyyy"), value = Args.StartDate, Operator = "greaterthanorequal" });
        predicate.Add(new WhereFilter() { Condition = "or", Field = employee.Date.ToString("dd/MM/yyyy"), value = Args.EndDate, Operator = "lessthanorequal" });
        Col1Pre = WhereFilter.And(predicate);
        Qry = new Query().Where(Col1Pre); // to filter the Grid
    }


VN Vignesh Natarajan Syncfusion Team December 14, 2020 09:54 AM UTC

Hi Leonardo,  
 
Query: “I have this data set from SQL server "employee.Date" and tried to run with no errors but doesn't search all the desired date pick my sample code below 
 
We have analyzed the provided code and we found that Field property of WhereFilter in OnChange event is wrongly defined. From the provided (previous udpate) code example, we suspects that employee in employee.Date represents the model class name and Date denotes the Field / column name. So we need to specify only the field name in Field property of WhereFilter class. Kindly define the value properly as per your previous update (11th December 2020).  
 
Refer the below code example.  
 
<SfGrid @ref="DefaultGrid" DataSource="@employeeList" Query="@Qry" AllowPdfExport="true" AllowPaging="true"> 
    <GridColumns> 
        <GridColumn Field=@nameof(employee.SenderName) HeaderText="Sender Name" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(employee.DocumentType) HeaderText="Document Type" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(employee.DateHeaderText="Date Routed" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(employee.Remarks) HeaderText="Remarks" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
  
  
@code{ 
    public void OnChange(RangeEventArgs Args) 
    { 
        var Col1Pre = new WhereFilter(); 
        var predicate = new List<WhereFilter>(); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "Date", value = Args.StartDate, Operator = "greaterthanorequal" }); 
        predicate.Add(new WhereFilter() { Condition = "or"Field = "Date", value = Args.EndDate, Operator = "lessthanorequal" }); 
        Col1Pre = WhereFilter.And(predicate); 
        Qry = new Query().Where(Col1Pre); // to filter the Grid 
    } 
} 
   
If you are still facing the reported issue, kindly get back to us with the details requested in previous update. Issue reproducible sample will be very helpful for us to validate the reported query at our end and provide solution as early as possible.   
 
Regards,
Vignesh Natarajan
 


Loader.
Up arrow icon