Developer forum

Forum » Development » Datalists - Issue with export excel when page has more than one datalist and possible workaround

Datalists - Issue with export excel when page has more than one datalist and possible workaround

Pedro Meias
Reply

Hi,

DW 9.17.8

Swift v1.26.3

This is share the issue we faced with datalists export to excel feature and the workaround we found.

When on a page that has more than 1 datalist - The downloaded file always had only the data from the first datalist even if the download url was from the template tag on the second datalist.

I have attached a video on the issue.

We did find a workaround I also wanted to share that.

We subscribed to the following notification

Dynamicweb.DataManagement.Notifications.Publishing.OnBeforeContent

and added a validation on the paragraphId.

Here is the full code

using System;
using Dynamicweb.Extensibility.Notifications;

namespace Dna.Keystone.Claim.NotificationsSubscribers
{
    [Subscribe(Dynamicweb.DataManagement.Notifications.Publishing.OnBeforeContent)]
    public class OnBeforeContent : NotificationSubscriber
    {
        public override void OnNotify(string notification, NotificationArgs args)
        {
            if (!(args is Dynamicweb.DataManagement.Notifications.Publishing.OnBeforeContentArgs beforeContentArgs))
            {
                return;
            }

            var requestMode = Dynamicweb.Context.Current.Request.QueryString.Get(Constants.Request.Mode);
            var requestViewParagraphId = Dynamicweb.Context.Current.Request.QueryString.Get(Constants.Request.ViewParagraphId);
            if (string.IsNullOrEmpty(requestMode) || string.IsNullOrEmpty(requestViewParagraphId)) return;

            if (!requestMode.Equals("excelexport", StringComparison.OrdinalIgnoreCase) || beforeContentArgs.ContentModule.Paragraph.ID == Dynamicweb.Core.Converter.ToInt32(requestViewParagraphId)) return;
            
            beforeContentArgs.StopExecution = true;
            beforeContentArgs.Output = string.Empty;
        }
    }
}

 

 


Replies

 

You must be logged in to post in the forum