I have created a custom order grid in magento. If I sort the grid once, an ajax request is made, and everything sorts correctly. However, the second sort renders the grid with all the same Order IDs.
This question have the same issue as mine: https://magento.stackexchange.com/questions/123707/magento-grid-component-not-sorting-correctly. Tried his solution but didn’t worked.
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">syncback_order_form.syncback_order_form_data_source</item>
<item name="deps" xsi:type="string">syncback_order_form.syncback_order_form_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">API URL Form</item>
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data</item>
<item name="namespace" xsi:type="string">syncback_order_form</item>
</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
<item name="buttons" xsi:type="array">
<item name="save" xsi:type="array">
<item name="name" xsi:type="string">save</item>
<item name="label" xsi:type="string">Save API</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">*/*/saveapi</item>
</item>
</item>
</argument>
<dataSource name="syncback_order_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">PanemiratesSyncbackorderUiComponentApiformDataProvider</argument>
<argument name="name" xsi:type="string">syncback_order_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">type_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="collectionFactory" xsi:type="object">PanemiratesSyncbackorderModelResourceModelCollectionsApisavercollectionFactory</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="submit_url" xsi:type="url" path="panemirates/status/saveapi"></item>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
<fieldset name="callback_form">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<!--
<item name="collapsible" xsi:type="boolean">true</item>
-->
<item name="label" xsi:type="string" translate="true">Callback URL</item>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="url">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">API Url</item>
<item name="formElement" xsi:type="string">input</item>
<!--
<item name="source" xsi:type="string">panemirates_apiurl</item>
<item name="dataScope" xsi:type="string">url</item>
<item name="default" xsi:type="string">${ console.log($.syncback) }</item>
-->
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
<item name="url-required" xsi:type="boolean">true</item>
<item name="validate-url" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
</fieldset>
</form>```
2
Answers
I had the same problem and found the answer in the link you provided, more specifically here https://magento.stackexchange.com/a/123884/58072
Just add this code inside your dataSource
May be I am replying late, but hope so it will help other like me. I am also facing same kind of issue and tried hard to solve it, but didn’t get any help. So I have gone through the core modules and found solution:
Add below line of code inside datasource element of your ui_component.
This resolved my issue.