Our pure JavaScript Scheduler component


Post by gitdev »

Hi,

I have the following eventRender. The produit variable is null, which then leads to an error when an event is created with the editor. Can I write something in there to allow not breaking the scheduler and only display an empty string when some of the objects are null ?
  eventRenderer = ({eventRecord}) => {
    return `
        <div class="info">
            <span style="font-weight:bold">${eventRecord.id} - </span>
          <span class="name">${eventRecord.produit.nom}</span>
        </div>
      `;
  }; 
Thanks

Post by pmiklashevich »

Sure! Anything inside `${ }` is a javascript expression. So you can write conditions like
${eventRecord.produit ? eventRecord.produit.nom : ''}
See docs: https://developer.mozilla.org/en-US/doc ... e_literals

Pavlo Miklashevych
Sr. Frontend Developer


Post by gitdev »

Thank you very much.

Post Reply