Visual Studio Lightswitch,创建一个自动更新浏览屏幕的搜索参数?

时间:2014-06-06 08:52:11

标签: c# javascript visual-studio-2013 lightswitch-2013

做了一些研究而没有找到任何东西...我已经为基本联系人表创建了一个LightSwitch应用程序.. Browse sceen包含名称,数字等...当我使用搜索参数时,是可能或此搜索文本框在每次击键后自动刷新?

例如我输入' A'并根据姓氏加载所有以A开头的姓氏,而不按回车键。

这可以通过内部设置完成吗?或者我需要使用JavaScript或C#>谢谢你的帮助

2 个答案:

答案 0 :(得分:1)

我是从http://blog.pragmaswitch.com/?p=1670得到的,而且效果很好。我在所有搜索屏幕中都使用它。

myapp.BrowseScreen.SearchText_postRender = function (element, contentItem) {
    // This block is from somewhere else, sets the focus to the search box
    $searchBox = $("input", $(element));
    setTimeout(function () {
        $searchBox.focus();
    }, 1);

    // The blog post linked above set the required characters to 3, but I liked the instant filtering of 1
    onInputAsYouType(element, 1, function (text) {
        contentItem.screen.SearchText = text; //SearchText here is the data item in the screen designer linked to the query parameter
    });

    function onInputAsYouType(element, numberOfRequiredChars, done) {
        var inputbox = $("input", $(element));
        inputbox.on("input", function (e) {
            var text = $(this).val();
            if (text.length >= numberOfRequiredChars)
                done(text);
        });
    };
};

你可以在博客文章中查看截图,但这非常简单。创建浏览/搜索屏幕,将搜索文本设置为文本框,然后将此代码插入后期渲染。

答案 1 :(得分:0)

我不知道您的代码,但您可能会尝试将代码直接插入" text_changed"你的textBox事件。

private void textBox_TextChanged(object sender, EventArgs e)
    {
        //your code here for instance, or call a method that contain your code
    }
相关问题