Code Monkey home page Code Monkey logo

Comments (16)

chuprik avatar chuprik commented on June 12, 2024

hello, have you used my column class? and additional question, can you show how you created dataProvidel? it's ArrayDataProvider?

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

little bit explanation:
1, 0, 2 from your screen, should be ID of models, no keys is correct values.
what ID you have in your CRUD? could you look data-id attribute in Sortable column?

from yii2-sortable-widgets.

beatep avatar beatep commented on June 12, 2024

Thanks for your quick answer.

Yes, I used your column class. My dataProvider is an ArrayDataProvider:
$dataProvider = new ArrayDataProvider([ 'allModels' => $model->kapitel, 'sort' => [ 'attributes' => ['id', 'username', 'email'], ], 'pagination' => [ 'pageSize' => 10, ], ]);

But 1,0,2 is not the id of my models, it's the new sorting order. How does the update method know, which id is concerned?
This is how my table column looks like...
d

from yii2-sortable-widgets.

beatep avatar beatep commented on June 12, 2024

Why I thought the ID is missing: This is how the sorting in my yii1 grid worked.
yii1

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

You have used another extension for yii1. I did another approach. So, I will check this problem today and will be back to you.

from yii2-sortable-widgets.

beatep avatar beatep commented on June 12, 2024

Did you find out enything?

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

hello, yes. could you change https://github.com/kotchuprik/yii2-sortable-widgets/blob/master/assets/files/js/sortable-widgets.js#L5 to data-id in your local file? and check sorting again?

from yii2-sortable-widgets.

beatep avatar beatep commented on June 12, 2024

Nothing has changed, sorry (I think I already tested that).

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

could you to do composer update, add rowOptions and check again? I've found problem with using ArrayDataProvider

from yii2-sortable-widgets.

babib2 avatar babib2 commented on June 12, 2024

Explain to me please. I can not sort the list. But when I add a parameter in the query string ?sort=order, then the list is sorted. Where this option is added in the code? Like this...

 public function actions()
    {
        return [
            'sorting' => [
                'class' => \kotchuprik\sortable\actions\Sorting::className(),
                'query' => \common\modules\test\models\Test::find()->addOrderBy('order'),
            ],
        ];
    }

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

Please, look the example addOrderBy is no needs. What with your post request now?

from yii2-sortable-widgets.

babib2 avatar babib2 commented on June 12, 2024

How should work sorting?
"Order" is changed immediately when perestanoke? I only changed when to reload the page. Lines menyut its position when moving. But the value of the field does not change the order. This is when the parameter ?sort=order.

Request URL:http://yiistart/backend/test/test/sorting/
FORM DATA
/index/?sort=order
sorting[]:8
sorting[]:9
sorting%5B%5D=8&sorting%5B%5D=9
sorting[]:9
sorting[]:8
sorting%5B%5D=9&sorting%5B%5D=8
/index
sorting[]:8
sorting[]:9
sorting%5B%5D=8&sorting%5B%5D=9
sorting[]:9
sorting[]:8
sorting%5B%5D=9&sorting%5B%5D=8

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

perestanoke, menyut — google translate RU-EN? :)

I don't understand your question. What do you want know?

You have next elements: 45, 94, 100. When you will swap 45 and 100, the extension will send:

sorting[]: 100
sorting[]: 94
sorting[]: 45

It means next 1st order for 100, 2nd order for 94 and 3rd order for 45. Number of position in array will be order for element.

From your example:

Before:

sorting[]:8
sorting[]:9

After:

sorting[]:9
sorting[]:8

It means that you have swapped 8 and 9. New order for 9 will be 1, for 8 will be 2.

from yii2-sortable-widgets.

babib2 avatar babib2 commented on June 12, 2024

I want to say that I have retained only if the permutation of the query string is the next attribute
?sort=order.
That is, I do sort by order.
A value in the column "order" changes only when you restart the page

from yii2-sortable-widgets.

beatep avatar beatep commented on June 12, 2024

yes, now it works! Thank you 👍

from yii2-sortable-widgets.

chuprik avatar chuprik commented on June 12, 2024

awesome :)

from yii2-sortable-widgets.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.