The sorting column in failing on several forms, what do we look for to fix this?
The sorting column in failing on several forms, what do we look for to fix this?
We have been using the same sort code for some time and I see that it is failing on several forms, good on others.
In the .js file we have for the column:
{ name: "articles.rowOrder", data: "articles.rowOrder", className: "reorder no-inline", },
And sorting js:
.on("postCreate postRemove", function() { table.ajax.reload(null, false); })
.on("initCreate", function() { editor.field("articles.rowOrder").enable(); })
.on("initEdit", function() { editor.field("articles.rowOrder").disable(); });
In the controller I copied in the code direct from the example page substituting the table and column names:
// ROWORDER BLOCK
->on( 'preCreate', function ( $editor, $values ) {
if (! $values['rowOrder']) {
// If no value submitted, then use the max+1 as the new value
$next = $editor->db()->sql('select IFNULL(MAX(rowOrder)+1, 1) as next FROM articles')->fetch();
$editor->field('articles.rowOrder')->setValue($next['next']);
}
else {
// On create update all the other records to make room for our new one
$editor->db()
->query( 'update', 'articles' )
->set( 'rowOrder', 'rowOrder+1', false )
->where( 'rowOrder', $values['rowOrder'], '>=' )
->exec();
}
} )
->on( 'preRemove', function ( $editor, $id, $values ) {
// On remove, the sequence needs to be updated to decrement all rows
// beyond the deleted row. Get the current reading order by id (don't
// use the submitted value in case of a multi-row delete).
$order = $editor->db()
->select( 'articles', 'rowOrder', array('id' => $id) )
->fetch();
$editor->db()
->query( 'update', 'articles' )
->set( 'rowOrder', 'rowOrder-1', false )
->where( 'rowOrder', $order['rowOrder'], '>' )
->exec();
} )
// ROWORDER BLOCK
What happens currently. When you drag the Sort column (last) it appears to respond but returns to the original position. The site is apache-restricted: To access the site:
www.smokeymo.xyz
username: guest
password: %guest%()
If you wish to access the form you will need to sign into your account or use a guest account:
email: uhavehighhopes@gmail.com
password: %guest%()
From the dashboard menu select DTE --> Public FAQ
Answers
Sounds like you are using RowReorder. The docs have this:
Possibly you need to use
orderFixed
to make sure the sorting column for RowReorder is always first.Are you using a numeric index for the column used to order the table? If not then the order may not be as expected. Take a look at this example
Kevin
They are sequential however this is a view of data where the page_type = 'public-faq'. I have been doing this for a long time and it usually works. Did you look at the demo page and try reordering a couple items?
When reordering the Editor sends this
edit
request to the server:The request represents swapping two rows. However the server is responding with these errors:
Not sure why because they appear to be in the parameters sent. The
articles.rowOrder
field is not updated in the server and when the table is refreshed viadraw()
the server side processing request showsrow_874
retains the originalarticles.rowOrder
of 7 androw_875
retains the originalarticles.rowOrder
of 6.Use the browser's network inspector to see the above. You server script will need to be debugged to learn why it is returning the fieldErrors.
Kevin
RowReorder will send only the changes values, as noted in
rowReorder.formOptions
. You can change that to be all value in the row with that option - e.g.:It isn't clear to me yet why it thinks
metatitle
and friends have changed, but try that and see if it helps. If not I'll dig deeper.Allan
I really don't understand the javascript, will pass that along to my partner. However, this does help.
1) Sequential - before submitting the post I looked (command line mysql) at the table, id and reorder fields - found a couple duplicates, fixed them. I used an sql that resets reorder starting at 1 incrementing each row, leaving clean data.
2) Seeing what you replied about meta- fields, I commented them out in the php and controller files. This did not help but removed some errors/warnings.
This is not a database field, is only a note/header field placed at the top of a section using CSS to hide the input.
3) I ran update queries to ensure that both metatitle and metadesc fields were all set to empty if NULL. No help, okay.
4) Still getting an error something like 'metadesc is not defined' even though commented out. Scratching my head for a few seconds.
5) Not comfortable with having potential administrators creating their own slug/alias, metatitle, and metadesc we/he created a function to generate meta data and slugs. I commented out the code in both the php/html file and controller for this form only and sorting works.
I believe this gives us the pointer we need to solve the problem. This type of work is not my fortay. In Firefox sometimes I use Web Developer and the Console, not much more. Can you point me to the path in web developer to see what you see?
I've just tried https://www.smokeymo.xyz/bin/public-faq and reordering by the last column appears to work okay as it is just now.
is submitted, which looks good to me and reloading the page leaves the data in the new order.
Allan
Yes I commented out the metaGeneration code in both files. For reference,with article, blog posts and faq like this which might have its own page, what the code does is 3 things:
1) It uses regex to create a people-friendly string out of the title
2) Upon New, it copies the original title into the metatitle and metadesc fields.
3) To avoid duplication it adds the ID to the beginning of the string something like:
1234-oh-what-a-tangled-web-we-weave
It's on us to figure this out now. Thx.
Haha! Good to hear you are making progress with it
Allan