Our pure JavaScript Scheduler component


Post by saki »

You get two records in the context: context.record is the record being moved (dragged) and context.insertBefore is the record before which to insert it (it will be undefined, if the record is dragged to the end).

So having this information you need to calculate new assemblyOrder (or any other persistent field value) and set it. I don't know how your server process the data but the following pseudo-code idea should work:

context.record.insertBeforeId = context.insertBefore ? context.insertBefore.id : 'last'; 
// insertBeforeId would be a persistent field ignored by UI at client

This way the server would be responsible for reordering.

Other approaches are also possible, for example to calculate new assemblyOrder for moved records and for other records. Something as:

const newAssemblyOrder = // some calculation logic here
record.assemblyOrder = newAssemblyOrder;

Post by Aniket »

Team,

Is there any field by default which maintains the order of resources shown in the scheduler?

Does id field in the resources maintain the order in whch it will be displayed on the scheduler?


Post by fabio.mazza »

Hi Aniket,

Is there any field by default which maintains the order of resources shown in the scheduler?

No, but you can get it using https://www.bryntum.com/docs/scheduler/#Core/data/Store#function-indexOf

scheduler.resourceStore.indexOf(resourceRecord);

Does id field in the resources maintain the order in whch it will be displayed on the scheduler?

No, the id is not related to the order, it is the record identifier and doesn't change on reorder things.

Best regards,
Fabio


Post by saki »

I have re-tested it with the following changes to our Crud Manager demo and I think it does what you want. Let us please know if that solves your issue.

  1. To add persistent field sortIndex we add it to resourceStore config:

        crudManager : {
            resourceStore : {
                // Add some custom fields
                fields : ['car', 'dt', {name:'sortIndex', type: 'number'}]
            },
        // etc
  2. Then we need the drop logic:

        features : {
            rowReorder:{
                listeners : {
                    gridRowDrop : ({ context }) => {
                        // setting the persistent field `sortIndex` triggers the autoSync
                        context.record.sortIndex = context.record.resourceStore.indexOf(context.record)
                    }
                }
            },

    Drag and drop then triggers the autoSync with updated sortIndex.


Post Reply