Sorting not working correctly custom order grid in magento 2 - magento2

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">Panemirates\Syncbackorder\Ui\Component\Apiform\DataProvider</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">Panemirates\Syncbackorder\Model\ResourceModel\Collections\ApisavercollectionFactory</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>```

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.
<settings>
<storageConfig>
<param name="cacheRequests" xsi:type="boolean">false</param>
</storageConfig>
<updateUrl path="mui/index/render"/>
</settings>
This resolved my issue.

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
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">column_id</item>
</item>
</item>
</argument>

Related

Material3: Unwanted White bg on text selection menu on AlertDialog

There is a white background when users select text and see copy/paste menu.
And you see handles are not the accentPrimary color too.
This happens on AlertDialogs which it's style is deriven from Theme.Material3.DayNight.Dialog.Alert
The dialog is built by AlertDialog.Builder(context, style)
These are the style attributes I am using for style variable above:
<item name="android:background"/>
<item name="android:windowTitleStyle"/>
<item name="android:textColorPrimary"/>
<item name="windowFixedWidthMajor"/>
<item name="windowFixedWidthMinor"/>
<item name="buttonBarNeutralButtonStyle"/>
<item name="buttonBarNegativeButtonStyle"/>
<item name="buttonBarPositiveButtonStyle"/>
<item name="android:windowMinWidthMajor"/>
<item name="android:windowMinWidthMinor"/>
<item name="android:buttonBarNeutralButtonStyle"/>
<item name="android:buttonBarNegativeButtonStyle"/>
<item name="android:buttonBarPositiveButtonStyle"/>
When I do not use these styles, the white bg is not there, but the editText's height becomes extremely thin.
What is the attribute in Material3 to change those colors and fix them?

How to override form in magento 2 (uiComponent)

I have form declared as uiComponent(custom module). I have to disable top menu button based on some status.
The button is in structure
<form>
<argument name="data" xsi:type="array">
<item name="buttons" xsi:type="array">
<item name="save_and_continue" xsi:type="array">
<item name="name" xsi:type="string">save_and_continue</item>
<item name="label" xsi:type="string" translate="true">Save and Continue Edit</item>
<item name="class" xsi:type="string">save_and_continue</item>
</item>
....
</item>
....
</form>
I try to create observer to remove element from view but using $layout->unsetElement('save_and_continue') not work. I found that there is some think like PHP modifiers in UI components but i cant get this right from tutorial provided in doc.
How can i remove remove such item ? It can`t be static xml to override this one because i have some dynamic parameters.
I end up doing is to override with my own class.
<item name="save_and_continue" xsi:type="string">
class\namespace....
</item>

how to set same page title for all the my account pages in magento 2?

I want to change all the my account page's title to My Account.
For Example:
If you go to My orders page the title will be My Orders by default, but it should be "My Account".
I do not recommend to change all of your titles in My Account, however if that's you want then here is how:
Find all files in the vendor/magento with name is customer_account.xml, the path must looks like module-*/view/frontend/layout/customer_account.xml.
For example, My Orders has been set in module-sales/view/frontend/layout/customer_account.xml.
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="customer_account_navigation">
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link">
<arguments>
<argument name="path" xsi:type="string">sales/order/history</argument>
<argument name="label" xsi:type="string" translate="true">My Orders</argument>
<argument name="sortOrder" xsi:type="number">230</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Change "My Orders" to whatever you want and repeat it over and over.
Cheers,

Magento 2 + UI Component don't get value in post

I am using htmlContent in Ui Component form. When i submit form i didn't get data in post which are using in htmlConent.
My Code is : request_form.xml
<fieldset name="request_item">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Products</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="opened" xsi:type="boolean">true</item>
</item>
</argument>
<container name="enduser_container" >
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<htmlContent name="request_price_items">
<!--<argument name="block" xsi:type="object">Extendway\Requestquote\Block\Adminhtml\Index\Edit\Requestproduct</argument>-->
<block class="Extendway\Requestquote\Block\Adminhtml\Index\Edit\Requestproduct" name="item_info" ></block>
</htmlContent>
</container>
</fieldset>
Template File is
<input type="text" name="quote_id" value="XXXX" />
I am not getting "quote_id" in Post data.
Please help what i am missing in HtmlConent & Ui Component file.
You need to add this attribute data-form-part="form-name" to your input.
Please change the form-name with your form name

How to move Apply Discount Code option at Checkout?

How to move Apply Discount code option after Order Summary section of payment step. In Vendor/Magento/Sales Rule/view/front-end/layout/checkout_index_index.xml I tried modifying the item name="afterMethods" but id didn't work.
You first need to remove the afterMethods component in your theme (which call the discount component): app/design/frontend/Vendor/themename/Magento_Checkout/layout/checkout_index_index.xml
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="afterMethods" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</item>
</item>
</item>
</item>
</item>
The discount component itself is defined in the Magento_SalesRule module. So Once it's deleted, you can add discount the component after the order summary component in app/design/frontend/Vendor/themename/Magento_SalesRule/layout/checkout_index_index.xml with something like this (code not tested, so maybe you'll need to fix it) :
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="sidebar" xsi:type="array">
<item name="children" xsi:type="array">
<item name="discount" xsi:type="array">
<item name="sortOrder" xsi:type="string">
<item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount</item>
<item name="children" xsi:type="array">
<item name="errors" xsi:type="array">
<item name="sortOrder" xsi:type="string">0</item>
<item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount-messages</item>
<item name="displayArea" xsi:type="string">messages</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>