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.
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
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 )
Can you help me to carry out that example with Sveltekit using your ej2 library?
thanks Manuel
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
any new news on how to implement Grid component with sveltekit? thanks
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
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 :
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:
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.
Regards
Aishwarya R
The link is not correct :
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
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