Use a grid in Dialog mode with template ( From svelte component )

I would like to use a grid in Dialog mode with template.


The problem is that i really want is to use a sveltekit component as a template (example. Tab1.svelte).


I have seen that the template parameter is a string, which makes it difficult to load the svelte component:


refGrid = new ej.grids.Grid({
columns: columns,
dataSource: data,
...
editSettings: { mode: `Dialog`, template: `${htmlTemplateDialog}`},
....


Could you give me an example of how to do it?


Any ideas?


P.S.: In your  Blazor  Grid Component, there is no problem in rendering a component as a template, but in ej2, I am having a lot of problems.


9 Replies

AR Aishwarya Rameshbabu Syncfusion Team September 25, 2024 01:46 PM UTC

Hi Manuel,


Greetings from Syncfusion support.


After reviewing your inquiry, we have identified that you are utilizing the dialog template feature of the Syncfusion Grid to render a Svelte Kit component as a dialog template. We are currently validating your requirement by creating a sample based on the information provided. However, we need additional details to offer a more precise solution. Kindly provide the following information:


1. The definition of the 'htmlTemplateDialog' template, including how you are importing and defining the Svelte component (example. Tab1.svelte) in your page.

2. The code within the Svelte component file that is intended to be used as a dialog template.

3. The specific Syncfusion package you are currently using.

4. The complete Grid rendering code, along with any event handler functions or templates utilized.



Regards

Aishwarya R



MA Manuel September 26, 2024 12:00 PM UTC

Dear Aishwarya  , 


Exactly, I want to implement this Grid example with custom dialog template into sveltekit project : 


https://stackblitz.com/edit/exrhvc?file=index.html


To do that , I am trying to do it in this way: ( with error ) 


https://stackblitz.com/edit/sveltejs-kit-template-default-qd3sv6?file=src%2Froutes%2Fgrid%2FTab2.svelte


Can you help me to carry out that example with Sveltekit using your ej2 library?


thanks Manuel



MA Manuel September 26, 2024 12:10 PM UTC

In short, the structure of the component would be:


+page.svelte --> Grid component


GridDetails.svelte -->  Grid custom template


Tab1.svelte --> Tab1 detail 


Tab2.svelte --> Tab2 detail


Image_3052_1727352513255



CH Carlos hullarte October 7, 2024 08:40 AM UTC

any new news on how to implement Grid component with sveltekit? thanks



AR Aishwarya Rameshbabu Syncfusion Team October 8, 2024 06:46 AM UTC

Hi Manuel,


Thanks for your valuable patience.


We are facing the problem with rendering the Svelte component in the Grid’s DialogTemplate feature when using a component reference defined in the editSettings.template property instead of the built-in option like ID of a script element or string template. We are treating this issue as a high priority, and further details will be communicated soon.


However, as per your last update, we have rendered the Tab component as a dialog template using the SvelteKit application with a standard JavaScript template.

Please review the code example below and the attached sample for more information


+page.svelte

grid = new Grid({

      columns: columns,

      dataSource: data,

      allowPaging: true,

      pageSettings: { pageSize: 5 },

      toolbar: ['Add', 'Edit', 'Delete'],

      editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog', template: '#dialogtemplate' },

          actionComplete: (args) => {

      if ((args.requestType === 'beginEdit' || args.requestType === 'add')) {

        var tabObj = new ej.navigations.Tab({

          showCloseButton: false,

          selecting:  (e) => {if(e.isSwiped) {e.cancel = true;} if(e.selectingIndex === 1) {e.cancel = !validate(1)}},

          items: [

              { header: { 'text': 'Details' }, content: '#tab1' },

              { header: { 'text': 'Verify' }, content: '#tab2' },

          ]

      });

      tabObj.appendTo('#edittab');

 

      new ej.dropdowns.DropDownList({value: args.rowData.ShipCountry, popupHeight: '200px', floatLabelType: 'Always',

      dataSource: countryData, fields: {text: 'ShipCountry', value: 'ShipCountry'}, placeholder: 'Ship Country'}, args.form.elements.namedItem('ShipCountry'));

 

      new ej.buttons.CheckBox({ label: 'Verified', checked: args.rowData.Verified }, args.form.elements.namedItem('Verified'));

      // Set initail Focus

      if (args.requestType === 'beginEdit') {

          (args.form.elements.namedItem('CustomerName')).focus();

      }

 

      document.getElementById('next').onclick = () => {

        moveNext();

    }

 

    function validate(tab) {

      let valid = true;

       [].slice.call(document.getElementById('tab' + tab).querySelectorAll('[name]')).forEach(element => {

          element.form.ej2_instances[0].validate(element.name);

          if (element.getAttribute('aria-invalid') === 'true'){

              valid = false;

          }

      });

      if (!valid) {

      return false;

      }

      return true;

     }

     function moveNext() {

      if (validate(1)) {

          tabObj.select(1);

      }

      }

 

      document.getElementById('submit').onclick = () => {

        if (validate(2)) {

            grid.endEdit();

        }

      }

    }

    }

    });

    grid.appendTo("#grid");

 

 

<main>

  <h1>Svelte Application!</h1>

  <div id="grid"></div>

   <script id="dialogtemplate" type="text/x-template">

      <div>

       <div id="edittab"></div>

           <div id="tab1">

               <div class="form-row" >

                   <div class="form-group col-md-6">

                       <div class="e-float-input e-control-wrapper">

                           <input id="OrderID" name="OrderID" type="text" value=${if(isAdd)} '' ${else} ${OrderID} ${/if} ${if(isAdd)} '' ${else} disabled ${/if} />

                           <span class="e-float-line"></span>

                           <label class="e-float-text e-label-top" for="OrderID">Order ID</label>

                       </div>

                   </div>

               </div>

               <div class="form-row" >

                   <div class="form-group col-md-6">

                       <div class="e-float-input e-control-wrapper">

                           <input id="CustomerName" name="CustomerName" type="text" value=${if(isAdd)} '' ${else} ${CustomerName} ${/if} />

                           <span class="e-float-line"></span>

                           <label class="e-float-text e-label-top" for="CustomerName">Customer ID</label>

                       </div>

                   </div>

               </div>

               <button id='next' class='e-info e-btn' style="float: right" type='button'> next</button>

           </div>

 

           <div id="tab2" style='display: none'>

               <div class="form-row" >

                   <div class="form-group col-md-6">

                       <input type="text" name="ShipCountry" id="ShipCountry" value=${if(isAdd)} '' ${else} ${ShipCountry} ${/if} />

                   </div>

               </div>

               <div class="form-row">

                   <div class="form-group col-md-6">

                       <input type="checkbox" name="Verified" id="Verified" ${if(isAdd)} '' ${else} checked ${/if} />

                   </div>

               </div>

               <button id='submit' class='e-info e-btn' style="float: right" type='button'> submit</button>

           </div>

       </div>

    </script>

</main>


Screenshot:



Regards

Aishwarya


Attachment: SveltekitApplication_de9c1cf4.zip


MA Manuel October 8, 2024 07:47 AM UTC

Dear  Aishwarya Rameshbabu, 

This solution you provide is not what I need.


I'd rather wait for the solution to integrate a slim component like the dialog template.


I only need to change the following block of code for sveltekit component , Like this :

Captura de pantalla 2024-10-08 094705.jpg






AR Aishwarya Rameshbabu Syncfusion Team October 10, 2024 06:04 PM UTC

Hi Manuel,


Following a comprehensive evaluation of the integration of Svelte components as templates in our Grid component, we would like to clarify that we do not support the Svelte platform directly. This includes native Svelte template compilation and other inherent features of Svelte.


Consequently, a feature request titled 'Svelte JS Framework Support' has been logged. During the planning phase of each release cycle, we review all open feature requests and prioritize them based on specific criteria such as product vision, technological feasibility, and customer interest. At present, there are no immediate plans to implement this feature, but it will be considered for future releases. You can monitor the status of your request, review the proposed resolution timeline, and reach out to us for further inquiries via the following link:


Feedback: https://www.syncfusion.com/feedback/34069/need-to-provide-support-for-html-tag-style-formatting-while-creating-pdf-using-ej2.


However, our JavaScript ES5 components are standalone and can be integrated into any platform that supports JavaScript, including Svelte applications. The template compilation in the ES5 platform operates based on the JavaScript engine, which only accepts JavaScript templates for compilation. For further details on how to pass various JavaScript templates, please refer to the documentation link below.

Documentation


Regards

Aishwarya R



MA Manuel October 23, 2024 11:36 AM UTC

The link is not correct : 

Feedback: https://www.syncfusion.com/feedback/34069/need-to-provide-support-for-html-tag-style-formatting-while-creating-pdf-using-ej2.


The team should consider making the library compatible with Svelte ( and sveltekit)  because it would significantly expand its user base and enhance its relevance in the modern web development landscape. Svelte is gaining popularity due to its unique approach to building user interfaces, focusing on performance and simplicity. 

By ensuring compatibility, the library could attract a new audience of developers who prefer Svelte's framework, thus increasing adoption and usage.


Overall, making the library compatible with Svelte would not only future-proof it but also foster innovation and community engagement.


Regards, Manuel



AR Aishwarya Rameshbabu Syncfusion Team October 24, 2024 08:01 PM UTC

Hi Manuel,


We sincerely apologize for the inconvenience caused.

Please refer to the appropriate feedback link for the feature request titled “Svelte JS Framework Support.”

Feedback: https://www.syncfusion.com/feedback/21926/svelte-js-framework-support


Regards

Aishwarya R


Loader.
Up arrow icon