This is a migrated thread and some comments may be shown as answers.
Inline creating row when data is sorted problem
10 Answers 84 Views
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 12 Apr 2016, 07:54 PM

I have a grid that uses inline editing. There are also many pages of data, and I noticed that if I sort by any column, then click the "Add new record" button, I don't see the new row appear (I assume it is created at the end of the last page). However when I go to the last page, the row is already created, except it is all blank! I have some required fields that the user needs to fill in before creating the row, but in this situation, the row is created by itself without any values. This blank row only appears on the frontend (doesn't do anything serverside), and clicking "Update" then "Cancel" removes the row from the table...

Preferably, I would like to be able to jump to the page that contains the created row so that the user doesn't have to go looking for a blank row if they try inserting while the grid is sorted.

Thanks

 

10 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 13 Apr 2016, 03:01 PM

http://dojo.telerik.com/Aveze

Here is a sample replicating the issue, if you sort the first column in descending order (click the column header twice) and try to add a row, it will be on the last page. When you go to the last page, the row is already "created" (not in edit mode)

0
Boyan Dimitrov
Telerik team
answered on 14 Apr 2016, 01:10 PM

Hello Andy,

I am afraid that this is expected behavior which is due to the way the new records' creation is handled. The "Add new record" in the KendoUI Grid inserts the new item before the first record from the current page position in the original (without sort, page, filtering etc. applied) data. When sorting is applied this new item's position may not match the current page - thus it may be not visible.

Regarding the required fields -  it is only UI validation and when the item is not on opened for edit the validation will not be triggered.  

I am afraid currently I can not suggest any suitable workaround to handle the right position of the newly inserted item.

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Andy
Top achievements
Rank 1
answered on 14 Apr 2016, 01:42 PM
Is there a way to clear all sorting/filters on "Insert new record" click?
0
Andy
Top achievements
Rank 1
answered on 14 Apr 2016, 02:50 PM
// clear filters/sort if the user wants to add a row
$(document).on("mouseup",'a.k-button.k-button-icontext.k-grid-add',function () {
      $("form.k-filter-menu button[type='reset']").trigger('click');
      $("#gridName").data("kendoGrid").dataSource.sort({});
});

 

Found a decent workaround, this removes all sorting and filters from the grid when you release the mouse button on "Add new record", and then you will be able to see the new row.

0
Matt
Top achievements
Rank 1
answered on 02 Nov 2017, 04:12 PM

I think this behaviour is illogical and not user friendly. The workaround is OK, but I don't think users should have to have their sorting reset when adding a new record.

Why shouldn't it be on the top row, where you'd expect it?

If someone creates a new entry, who would expect to navigate to another page before they can set the attributes?!! By that time, the row is no longer editable and fields say 'not defined'.

Definitely not professional.

0
Stefan
Telerik team
answered on 06 Nov 2017, 10:01 AM
Hello, Matt,

Thank you for the feedback.

I will forward this to the developers' team to check if we can make changes to the Grid Add new records behavior in order to take the current sorting criteria into account.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David
Top achievements
Rank 1
answered on 09 Apr 2018, 07:09 PM
Has there been an update to this issue?
0
Stefan
Telerik team
answered on 10 Apr 2018, 07:16 AM
Hello, David,

Currently, the behavior is not changed as changing it will cause a breaking change in the widget.

I can agree that this may be strange behavior, but it is required in the current implementation.

I can suggest submitting a feature request and based on the community feedback we may implement it in a future release:

http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback?category_id=170280

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Alessandro Stefano
Top achievements
Rank 1
answered on 29 Dec 2020, 10:37 AM

 

 

$(".k-grid-add").on("click", function (e) {
                var grid = $("#gridClienti").data("kendoGrid");
                grid.dataSource.sort({});
                //var dataSource = grid.dataSource;
                //var pageNumber = dataSource.data().length;
                //dataSource.insert(pageNumber, {});
                //dataSource.page(dataSource.totalPages());
                //grid.editRow(grid.tbody.children().first());
            });[quote]Stefan said:Hello, David,

Currently, the behavior is not changed as changing it will cause a breaking change in the widget.

I can agree that this may be strange behavior, but it is required in the current implementation.

I can suggest submitting a feature request and based on the community feedback we may implement it in a future release:

http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback?category_id=170280

Regards,
Stefan
Progress Telerik

Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.

[/quote] This my solution

0
Aleksandar
Telerik team
answered on 31 Dec 2020, 07:27 AM

Hi Alessandro,

Thank you for sharing your approach with the community, I am sure someone would find it useful. This workaround will indeed also remove the sorting of the Grid and the newly created item will appear on the top row.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Andy
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Matt
Top achievements
Rank 1
Stefan
Telerik team
David
Top achievements
Rank 1
Alessandro Stefano
Top achievements
Rank 1
Aleksandar
Telerik team
Share this question
or