× Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues

Show on list view no longer working correctly

7 năm 3 tháng trước #1470 bởi alex
I have a field J_SQL

It is a select of virtuemart products.

On the list view it always has shown the "selected" product. ie the value in the database.

Now, after my last rebuild the list view shows all the same product , which is the "lowest id" in the virtuemart product database.
Đính kèm:

Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.

7 năm 2 tháng trước #1484 bởi Chris
I see same problem. I checked my database, data is saving correctly, but showing incorrectly on admin list view.

Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.

7 năm 2 tháng trước #1485 bởi Chris
I was able to adjust the query in the list model, adding a left join, grabbing the correct data. Then I edited the view file, showing the "name" rather than the "id" of the field in question. This challenged my SQL skills, but solved the problem.

Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.

7 năm 2 tháng trước #1487 bởi alex
so how did you solve this?

can you post it here?

Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.

7 năm 2 tháng trước #1490 bởi Chris
Alex, Something like this...

let's say you have "items" and "parents". You want to show a list of items with the correct parent name.

Modify the query in the model, adding #__parents.name AS parentName in the select().
Modify the query further, adding a LEFT JOIN ON item.parent_id = #__parents.id.

Notice the parentName alias, this is important. I think I also aliased the table name simply to reduce typing, not important.

Now go into your view. Instead of displaying parent_id, display parentName. You probably don't have a "parentName" column in your #__parents table, that's ok, we created one on the fly with our alias.

I had to brush up on MySql joins as well as the JDatabase query() object.

As always for testing, in the model, before "return $query", add var_dump( $query->__toString() ); die; so that you can monitor the query. Cut and paste into PHPMyAdmin to test.

As an alternative, blow away the query found in the model, and write your own, might be simpler. Just remember to join "name" from the "parents" table as an alias.

That's as specific as I can explain, hope it helps.
Những thành viên sau(s) đã Cảm ơn: Andres Maeso

Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.

Thời gian tải trang: 0.143 giây
Powered by Kunena Forum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.