小编Smi*_*ith的帖子

如何允许用户在Select2上选择空字符串

使用Select2通过远程调用动态填充texbox,我希望允许用户将该字段留空.

$("#e6").select2({
    placeholder: "Search for a movie",
    minimumInputLength: 1,
    ajax: { 
        url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
        dataType: 'jsonp',
        data: function (term, page) {
            return {
                q: term, // search term
                page_limit: 10,
              };
        },
        results: function (data, page) { 
            return {results: data.movies};
        }
    },
 });
Run Code Online (Sandbox Code Playgroud)

这是一个工作示例http://ivaynberg.github.io/select2/index.html#ajax

jquery jquery-select2

20
推荐指数
2
解决办法
4万
查看次数

在select2中预选值

Texbox使用Select2动态填充远程调用,如何设置预选值.这是代码

<input type="hidden" id="e6">

$("#e6").select2({
    placeholder: "Search for a movie",
    minimumInputLength: 1,
    ajax: {
        url: url,
        dataType: 'jsonp',
        data: function (term, page) {
            return {
                q: term, // search term 
                page_limit: 10, }; 
        }, 
        results: function (data, page) { 
                return {results: data};
        }
    }
});    
Run Code Online (Sandbox Code Playgroud)

我试着预先选择值1049

$('#e6').select2('val', '1049');

但是这不会在文本框中设置值.

有任何想法吗?

javascript jquery jquery-select2

7
推荐指数
2
解决办法
2万
查看次数

如何允许临时表接受空值

如果在SQL Server中使用"insert into"创建临时表,则使用第一个插入来确定列是否接受空值.如果第一个插入具有空值,则该列可以为空,否则它将是不可为空的.

有没有办法使用"insert into"创建临时表来接受空值?

这没有任何问题

Select 'one' as a , null as b
into #temp

insert into #temp
Select 'two' as a , 500 as b
Run Code Online (Sandbox Code Playgroud)

但是这会抛出"无法将值NULL插入列'b'"

Select 'one' as a , 500 as b
into #temp

insert into #temp
Select 'two' as a , null as b
Run Code Online (Sandbox Code Playgroud)

我知道我可以做create Tablealter column声明,但我想这样做而不重写数百个现有的查询.

sql null temp-tables sql-server-2008-r2

5
推荐指数
2
解决办法
2万
查看次数