在我的屏幕中,我创建了一个选项卡控件,其中包含每个选项卡的多个表/查询。为了解决一些性能问题,每个表都禁用了自动执行查询选项。我能够手动加载表格并使排序和分页工作。但是,内置搜索不再起作用。
这是屏幕的代码片段:
partial void MyScreen_Activated()
{
this.FindControl("children").ControlAvailable += new EventHandler(TabControlAvailableHandler);
}
void TabControlAvailableHandler(object sender, ControlAvailableEventArgs e)
{
TabControl control = e.Control as TabControl;
control.SelectionChanged += TabControlChangeHandler;
}
private void TabControlChangeHandler(object sender, SelectionChangedEventArgs e)
{
var tab = (TabControl)sender;
var tabitem = tab.SelectedItem as TabItem;
if (tabitem == null)
{
return;
}
var cip = tabitem.Content as Microsoft.LightSwitch.Presentation.Framework.ContentItemPresenter;
if (cip == null)
{
return;
}
LightSwitchApplication.UserCode.Helpers.LightswitchUiHelper.LoadContentItemValues(cip.ContentItem);
}
我的朋友创建了一个特殊的助手并解决了排序/分页问题。
这是帮助程序的代码片段:
///
/// Recursively loads the bindings of the content item and its ChildItems.
///
/// The dispatcher.
/// The content item.
internal static void LoadContentItemValues(IDispatcher screenDispatcher, IContentItem contentItem)
{
foreach (IContentItem tmp in contentItem.ChildItems)
{
LoadContentItemValues(tmp);
}
if (contentItem.Value != null)
{
LoadMethod(contentItem);
var objectWithDetails = contentItem.Value as Microsoft.LightSwitch.IObjectWithDetails;
var detailsWithModel = objectWithDetails == null ? null : objectWithDetails.Details as Microsoft.LightSwitch.Details.IDetailsWithModel;
var contentProperty = detailsWithModel as INotifyPropertyChanged;
if (contentProperty != null)
{
Dispatchers.Main.Invoke(() => {
contentProperty.PropertyChanged += (s, e) => {
switch (e.PropertyName)
{
case "PageNumber":
case "SortDescriptors":
screenDispatcher.BeginInvoke(() => {
LoadMethod(contentItem);
});
break;
}
};
});
}
}
}
///
/// Execute the Load() method of the value.
///
/// The content item.
static void LoadMethod(IContentItem contentItem)
{
if (contentItem.Value != null)
{
var loadmethod = contentItem.Value.GetType().GetMethod("Load");
if (loadmethod != null)
{
loadmethod.Invoke(contentItem.Value, null);
}
}
}
问题是我无法获得正确的解决方案来使内置搜索功能正常工作。我在这里错过了什么吗?所有可能的解决方案将不胜感激。提前致谢!
问候,
艾伦·托伦蒂诺