joinWith not showing results


I noticed joinWith will not show records in the datagrid that do not use the relation.

I would expect the data to still show in the datagrid but obviously not the related data if it does not exist.

How can I get around this?


Any ideas?

Hi James,

Probably you need to elaborate your problem in detail.

What code do you use to construct the data provider, and what code do you use to show the grid view?

And what is the relation like?


Here is the code …

public function search($params) {


	$query = OfficeListing::isAccount(OfficeListing::find());




	$activeDataProvider = new ActiveDataProvider(["query" => $query]);


	$activeDataProvider->sort->attributes["propertyName"] = [

		"asc" => ["" => SORT_ASC],

		"desc" => ["" => SORT_DESC]



	if(!$this->load($params) || !$this->validate())

		return $activeDataProvider;


	$query->andFilterWhere(["like", "", $this->propertyName]);


	return $activeDataProvider;



If OfficeListing has no relation to a Property the OfficeListing record will not show in the datagrid.

I was expecting the OfficeListing record to show in the datagrid but just show {not set} for the property columns.

Is this possible?

What is the relation between OfficeListing and Property?

Which one has the foreign key to the other? And is there a foreign key constraint?

There is one Property to many OfficeLsting.

There is many OfficeListing to one Property.

There is no foreign key constraint set in the DB.

I see.

Just for confirmation:

The office_listing table has a foreign key to the property table,

and the foreign key can be null (meaning the office_listing record may or may not have a property).

Is that right?

And it seems very natural to me that any record without a property will not show when the "propertyName" of the search model is not empty.

If you mean to say that the records without a property should show when the "propertyName" is empty, then I agree with you. They should.

Is there any possibility that "isAccount()" filters out the records without a property?