After row is dropped to a different position Flat data wont update Index to the row position.

hi team,

After row is dropped to a different position Flat data wont update Index to the row position. Is this supposed to be like that? If so what is the correct way to save order from gantt component?

Between page navigation the row order is not persisted, how can we implement this?

I am using the below link for CRUD using similar batchsave endpoint


I am using Flatdata like using parentId to bind child records.


https://ej2.syncfusion.com/angular/documentation/gantt/managing-tasks/maintaining-data-in-server

Thanks,

Dayakar.



3 Replies

AG Ajithkumar Gopalakrishnan Syncfusion Team July 27, 2023 01:00 PM UTC

Hi Dayakar,

Greetings from Syncfusion,

Query#1: After row is dropped to a different position Flat data wont update Index to the row position. Is this supposed to be like that? If so what is the correct way to save order from gantt component?.

We will maintain indexes of flat data in non-virtual mode after row drag and drop, but the virtual sample will not be updated with proper indexing when drag drop since dynamic updating of data when scrolling. Please share your sample code so we can further discuss and provide more details. Additionally, we have attached a sample which demonstrates how to maintain the row index in the server while drag and drop. Please refer to the below link and implement it in your sample. If you still face the issue after trying all this, please get back to us.

https://ej2.syncfusion.com/documentation/gantt/how-to/maintain-record-index


Query#2: Between page navigation the row order is not persisted, how can we implement this?

Could you please provide us with the following information for further validation:

- Are you using any other customization for row order?
- Please provide the exact replication steps to reproduce the issue.

- Have you used any other customization to render the gantt?
- Please provide a code sample.
- Additionally, please include a code snippet of the data source, task field, and view type of the gantt.

Regards,
Ajithkumar G



DR Dayakar Reddy Borampeta July 27, 2023 05:00 PM UTC

HI Ajith,


Thank you for the reply,

https://ej2.syncfusion.com/documentation/gantt/how-to/maintain-record-index


i could not find some of the methods , can you provide this methods?

FindChildRecords 
FindDropdata
this.InsertAtTop
his.Insert




LA Lokesh Arjunan Syncfusion Team July 28, 2023 09:10 AM UTC

Hi Dayakar


In client side sample we will pass the dragged record, position of the record to be dropped, task id of dragged record and dropped record to server side. Please check the below code snippet for details.


rowDrop: function (args) {

        let record = this.flatData[args.fromIndex][this.taskFields.id];

        let record2 = this.flatData[args.dropIndex][this.taskFields.id];

        let data: IGanttData = args.data[0];

        let uri = 'https://localhost:44379/Home/RowDropMethod';

        let dragdropdata = {

             record: data[0].taskData,

             position: args.dropIndex,

             dragidMapping: record,

             dropidMapping: record2

        };

        let ajax = new Ajax(

        {

            url: uri,

            type: 'POST',

            contentType: "application/json",

            data: JSON.stringify(dragdropdata),

        });

        ajax.send();

     }


Using those parameters you can use your server code to maintain record index. insert, insertAtTop, FindChildRecords, and FindDropData. These methods simulate saving and retrieving data from a database, although the below code is simplified and does not connect to an actual database.


// Method to insert a new record at the end of the database

    public bool Insert(Record data)

    {

        database.Add(data);

        return true;

    }

 

    // Method to insert a new record at the beginning of the database

    public bool InsertAtTop(Record data)

    {

        database.Insert(0, data);

        return true;

    }

 

    // Method to find child records based on a given parent record id

    public List<Record> FindChildRecords(int parentId)

    {

        var childRecords = database.Where(record => record.ParentId == parentId).ToList();

        return childRecords;

    }

 

    // Method to find records based on specific drop data

    public List<Record> FindDropData(string dropData)

    {

        var matchingRecords = database.Where(record => record.DropData == dropData).ToList();

        return matchingRecords;

    }


Again, please note that this is just a simplified mockup to demonstrate the logic. In a real application, you'd need to use appropriate database connections and queries to interact with the database efficiently and securely.


Documentation link: https://ej2.syncfusion.com/documentation/gantt/how-to/maintain-record-index


Regards,

Lokesh


Loader.
Up arrow icon