Comments (5)
Can you paste the part of your config you are working on, also what your tables configuration is, and what you are trying to achieve?
from express-admin.
Of course. I need to have categories, many of them with sub-categories. I'm doing this through a column called "parent" which basically has the ID of another category. If this column's value is 0 this category has no Parent.
For the settings of this table as it is today, here goes:
"categories": {
"slug": "categories",
"table": {
"name": "categories",
"pk": "id",
"verbose": "Categories"
},
"columns": [
{
"name": "id",
"verbose": "id",
"control": {
"text": true
},
"type": "int(11)",
"allowNull": true,
"defaultValue": null,
"listview": {
"show": false
},
"editview": {
"show": true
}
},
{
"name": "name",
"verbose": "Name",
"control": {
"text": true
},
"type": "varchar(255)",
"allowNull": false,
"defaultValue": null,
"listview": {
"show": true
},
"editview": {
"show": true
}
},
{
"name": "parent",
"verbose": "parent",
"control": {
"select": true
},
"oneToMany": {
"table": "categories",
"pk": "id",
"columns": [
"nome"
]
},
"type": "int(11)",
"allowNull": true,
"defaultValue": 0,
"listview": {
"show": true
},
"editview": {
"show": true
}
},
],
"mainview": {
"show": true
},
"listview": {
"order": {},
"page": 25
},
"editview": {
"readonly": false
}
}
from express-admin.
I just came across this problem :(
How can it solve?
from express-admin.
The query generated for the listview looks like this
SELECT `tbl`.`id` AS __pk,`tbl`.`name`,
GROUP_CONCAT(DISTINCT CONCAT_WS(' ',CAST(`tbl`.`name` AS CHAR))) AS `parent`
FROM `tbl`
LEFT JOIN `tbl` ON `tbl`.`parent` = `tbl`.`id`
GROUP BY `tbl`.`id` ORDER BY `tbl`.`id` ASC LIMIT 0,25 ;
but in case of a self reference, it should be transformed to this
SELECT `tbl`.`id` AS __pk,`tbl`.`name`,
GROUP_CONCAT(DISTINCT CONCAT_WS(' ',CAST(`tbl2`.`name` AS CHAR))) AS `parent`
FROM `tbl`
LEFT JOIN `tbl` `tbl2` ON `tbl2`.`parent` = `tbl`.`id`
GROUP BY `tbl`.`id` ORDER BY `tbl`.`id` ASC LIMIT 0,25 ;
the only difference is the alias
I'll definitely think about it
from express-admin.
@ellahn @theRichu just pushed to master, if you are anxious to try it out just pull (it's not published to npm yet)
from express-admin.
Related Issues (20)
- nsp security issues HOT 1
- Store comma seperated values for a single column.
- Passing parameters to /add in order to prevalue fields
- mysql insert operation not working in -v (development, no login) mode HOT 1
- Time is not shown correctlly for mysql db HOT 1
- Unhandled exception when paginating empty resultsets
- Ajax call not working
- Error creating entry with many to many relationship
- crashes under Firefox Quantum 62.0 (64-bit) under OSX
- Support for postgres data type json? HOT 4
- ERROR! Could not find `pg` or `pg.js` module HOT 1
- Can this be used with hapijs? HOT 1
- PG setup via connection string
- Datepicker saving timezone with timestamp HOT 1
- Empty one to Many HOT 4
- Filter in tables throw internal server error HOT 1
- Password authentication fails for Postgres (11) connections HOT 4
- Flash of unstyled content HOT 3
- how to configure server using nodemon HOT 1
- what is mean for this error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-admin.