igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

igx-tree-grid- when placed inside angular template driven form, pagination click is considered as form submission

Open prabakaran1311 opened this issue 7 years ago • 6 comments

Description

When igx-tree-grid is placed inside angular template driven form, pagination click is considered as form submission. May be pagination buttons are of type="submit", hence invoking form submit method. Is there a way to configure pagination buttons or is there any other cause for this issue?

  • igniteui-angular version: 7.2.4
  • browser: IE 11

Steps to reproduce

  1. Place 'igx-tree-grid' (with [perPage]="5" [paging]="true") inside angular template driven form (say, name="formTest" role="form" (ngSubmit)="onSubmit()" #formTest="ngForm")
  2. Click on next page in the grid.

Result

This invokes onSubmit() method.

Expected result

This shouldn't invoke onSubmit() method and must display next page data in the grid.

Attachments

Attach a sample if available, and screenshots, if applicable.
image

prabakaran1311 avatar May 20 '19 20:05 prabakaran1311

A <button> element is by default of type="submit". Just add type="button" to the pager buttons.

kdinev avatar May 21 '19 11:05 kdinev

Could you please share sample code to add type="button" to igx-tree-grid pager buttons.

prabakaran1311 avatar May 21 '19 13:05 prabakaran1311

I added type="button" attributes to the paging buttons in the tree grid paging sample in this stackblitz example

kdinev avatar May 21 '19 14:05 kdinev

I did not use [paginationTemplate]="pager" in my actual code (though you can see it in the screenshot that I included here). I just added [perPage]="5" [paging]="true" to get pagination. Is there any way I could make this work without using [paginationTemplate]="pager"?

prabakaran1311 avatar May 21 '19 16:05 prabakaran1311

Well, without the template, if the tree grid absolutely has to be inside a form element, then no. But if it doesn't have to be, then if you move it outside the form, it wouldn't submit.

kdinev avatar May 21 '19 16:05 kdinev

I did not add the template as pagination was working fine without that (except for this issue). I added it now and it doesn't submit now. Thanks for your quick responses. My issue is resolved.

prabakaran1311 avatar May 21 '19 18:05 prabakaran1311