0
votes

I need the extjs 4 behaviour for new model objects to have a null id rather than a "Model-1" generated value in extjs 5+

Therefore I have created a id generator

Ext.define('Example.data.identifier.Custom', {
    extend : 'Ext.data.identifier.Generator',
    alias : 'data.identifier.custom',

    generate : function() {
        return null;
    }

});

But now my grid grouping features behave strange. I think it has to do with the id assigned to the additional grouping row to be also null.

Is there a way around?

1

1 Answers

0
votes

The ExtJS 4 behaviour of null ids does not work in ExtJS 5+ - you need to have ids, especially for objects in stores.

So accept the fact that all of your Model instances will need to have id values. You can determine if they were created locally or via retrieving from the backend using the phantom property. You can use a custom proxy to strip the id property when saving if you need to. You can use different endpoints with the AJAX proxy, or different HTTP Request Methods with the REST Proxy, so your backend can know if you are making a new record or updating an existing one.

But you can't get away with having duplicate IDs, including null values. Accept that, and move on.