To send city Id as filter (lookup table js file)
listAction: {
ajaxFunction: _institutionsService.getAll{{NP_Foreign_Entity_Name_Here}}ForLookupTable,
inputFilter: function () {
return {
filter: $('#SchoolTableFilter').val(),
cityId:$('#CityIdFilter').val(), // <---
};
}
},
To filter the schools by cityId,
var query = _schoolRepository.GetAll()
.WhereIf( !string.IsNullOrWhiteSpace(input.Filter), e=> e.SchoolName.ToString().Contains(input.Filter))
.WhereIf( input.CityId != null, e=> e.CityId == input.CityId); // <---
Use "CityId" instead of "cityId". Looks like There is a case mismatch.
<a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/1048">https://github.com/aspnetzero/aspnet-ze ... ssues/1048</a>
it may be same problem.
are other parameters also not passed?
@avanekar02 i assumed you are working on angular, my bad.
But key point is same. Pass the selected city id value to spot lookup modal and use it as a filter.
in create or edit modal:
$('#OpenSpotLookupTableButton').click(function () {
var entity = _$entityInformationForm.serializeFormToObject();
_spotLookupTableModal.open({ id: entity.spotId, displayName: entity.spotName, cityId: entity.cityId}, function (data) { // we added cityId: entity.cityId parameter here
_$entityInformationForm.find('input[name=SpotName]').val(data.displayName);
_$entityInformationForm.find('input[name=SpotId]').val(data.id);
});
});
it passed cityId to controller:
In controller:
public PartialViewResult SpotLookupTableModal(long? id, string displayName, int cityId)
{
var viewModel = new SpotLookupTableViewModel()
{
Id = id,
DisplayName = displayName,
CityId = cityId, // declare a CityId variable in SpotLookupTableViewModel
FilterText = ""
};
return PartialView("_SpotLookupTableModal", viewModel);
}
Then Create a hidden input in _SpotLookupTableViewModal
<input class="form-control" id="CityIdFilter" value="@Model.CityId" type="text" name="CityId" hidden/>
Now you can use it to filter spots when you call getAllSpotForLookupTable.
I also realized that and created a pull request yesterday <a class="postlink" href="https://github.com/aspnetzero/documents/pull/72">https://github.com/aspnetzero/documents/pull/72</a>
Try to re-build the solution. At least there should be an error message.
When you select a city, id and name of the selected city are saved. ( in getNewCityId() method )
So, you can pass the cityId or cityName variable to lookup component and use it as a filter there.
openSelectSpotModal() {
this.spotLookupTableModal.id = this.X.spottId;
this.spotLookupTableModal.displayName = this.spotName;
this.spotLookupTableModal.filterText = this.X.cityName; // <- add this to filter the spots
this.spotLookupTableModal.show();
}
Also, call getAll() when the lookup modal is shown. (in show() method)
Or you can pass the id and use it in getAllSpotForLookupTable method. And it is a better way.
What are these errors? There may be some overlooked cases that causes application not to build. But even in the worst scenario, error should be fixable by small touches.
Have you added DbSet property of your entity in DbContext?
public virtual DbSet<Class1> Class1 { get; set; }