D
D
des1roer2015-03-24 07:26:42
Yii
des1roer, 2015-03-24 07:26:42

Yii custom checkboxlist?

The task seems to be simple. There is a table id\ancestor\name. Normally. I want to implement the following - display a checkboxlist with an indent from the descendants.
[ ] root
[ ] __ 1.1
[ ] __ 1.2
But listData does not allow to change the output field from the database, maybe it's somehow corrected in checkBoxList?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2015-05-06
@des1roer

Before pushing an array into the checkboxlist, iterate over it and insert "__"

D
des1roer, 2015-05-07
@des1roer

the case was resolved by postgres query indeed

$sql = '
WITH RECURSIVE temp1 ( id,id_parent,name,PATH, LEVEL, NAME ) AS (
SELECT T1.id,T1.id_parent, T1.name, CAST (T1.id AS VARCHAR (50)) as PATH, 1 ,
CAST (T1.name AS VARCHAR (255)) as NAME
FROM vgok_site.t_department T1 WHERE T1.id_parent = 0
union
select T2.id, T2.id_parent, T2.name, CAST ( temp1.PATH ||\'->\'|| T2.id AS VARCHAR(50)) ,LEVEL + 1 ,
CAST ((repeat(\' _ \', LEVEL+1)||T2.name) AS VARCHAR(255))
FROM vgok_site.t_department T2 INNER JOIN temp1 ON( temp1.id= T2.id_parent))
select * from temp1 ORDER BY PATH LIMIT 100 
';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question