如何在jqgrid中增加表单中的自动完成组合文本元素宽度

如何在jqgrid中增加表单中的自动完成组合文本元素宽度,jqgrid,Jqgrid,在“编辑和添加表单”中,所有字段的宽度都是固定的 我试图增加“编辑/添加自宽度”,但输入元素的宽度仍然很小 太小,小于colmodel中定义的列宽 如何增加这些宽度或使其与colmodel中定义的相同? 标签列偏差太大。如何减少标签列宽,以便 其宽度等于最大标签文本宽度 更新1 colmodel包含自动完成组合框 {name:"AutocompleteWidthIssue", edittype:"custom", editoptions:{ maxlength:54, size:

在“编辑和添加表单”中,所有字段的宽度都是固定的

我试图增加“编辑/添加自宽度”,但输入元素的宽度仍然很小 太小,小于colmodel中定义的列宽

如何增加这些宽度或使其与colmodel中定义的相同? 标签列偏差太大。如何减少标签列宽,以便 其宽度等于最大标签文本宽度

更新1

colmodel包含自动完成组合框

{name:"AutocompleteWidthIssue",
edittype:"custom",
editoptions:{
    maxlength:54,
    size:54,
    custom_element:function(value, options) {
    return combobox_element(value, options,'17','test','Summak','Tululiik')
    },
    custom_value:combobox_value
},
editable:true,
width:39,
fixed:true
},


function combobox_element(value, options, width, colName, entity, andmetp) {
    var elemStr = '<div><input style="width:' + width + 'px" value="' + value + '"/>' +
'<button type="button" style="height:20px;width:20px;vertical-align:center;margin-left:-2px" tabindex=-1/></div>';
    var newel = $(elemStr)[0];

    input.autocomplete({
        source: 'Grid/GetLookupList'
    }
);

    $("button", newel)
    .button({ icons: { primary: 'ui-icon-triangle-1-s'} })
       });

    return newel;
}
{name:“自动完成宽度问题”,
编辑类型:“自定义”,
编辑选项:{
最大长度:54,
尺码:54,
自定义元素:函数(值、选项){
返回组合框元素(值、选项、'17'、'test'、'Summak'、'tululik')
},
自定义_值:组合框_值
},
是的,
宽度:39,
修正:正确
},
函数组合框\元素(值、选项、宽度、colName、entity和metp){
var elemStr=''+
'';
var newel=$(elemStr)[0];
input.autocomplete({
来源:“Grid/GetLookupList”
}
);
$(“按钮”,纽尔)
.button({icons:{primary:'ui-icon-triangle-1-s'}})
});
返回纽埃尔;
}
在内联编辑模式下,上面的代码以正确的宽度呈现组合框, 大小:54被忽略


如何仅在表单编辑/添加模式下增加自动完成文本输入元素的宽度,以便其文本元素宽度从大小或其他属性中获取宽度

尝试使用
编辑选项:{size:35,maxlength:45}
。也许这就是你需要的。它应该增加相应列的输入元素的大小,以便能够在不滚动数据的情况下输入大约35个字符。禁止输入超过45个字符。您可能需要增加Edit/Add form参数的默认值300,以便在不进行水平滚动的情况下显示表单的所有输入元素

不应对长标签进行其他设置。表格位于表格上,自动增加列宽

已更新:您可以对父
使用
显示:内联块
,它包含由
自定义\u元素返回的HTML片段
。下面的代码

function combobox_element(value, width) {
    var elemStr = '<div>' +
                  '<input class="FormElement ui-widget-content ui-corner-all" ' +
                  'style="vertical-align:top;width:' +  width + 'px" value="' +
                  value + '"/>' +
                  '<button class="ui-widget-content ui-corner-right ui-button-icon"' +
                  ' style="height:22px;width:22px;" tabindex="-1" /></div>',
        newel = $(elemStr)[0];

    setTimeout(function () {
        $(newel).parent().css({display: "inline-block"})
                .parent().css({'padding-bottom': 0});
        $('input:first', newel).autocomplete({
            source: 'Grid/GetLookupList'
        });

        $("button", newel).button({
            icons: { primary: 'ui-icon-triangle-1-s'},
            text: false
        });
    }, 50);

    return newel;
}
函数组合框\元素(值、宽度){
var elemStr=''+
'' +
'',
newel=$(elemStr)[0];
setTimeout(函数(){
$(newel).parent().css({display:“inline block”})
.parent().css({'padding-bottom':0});
$('input:first',newel).自动完成({
来源:“Grid/GetLookupList”
});
$(“按钮”,newel)。按钮({
图标:{primary:'ui-icon-triangle-1-s'},
文本:false
});
}, 50);
返回纽埃尔;
}
将产生


您将找到相应的演示。

尝试使用
编辑选项:{size:35,maxlength:45}
。也许这就是你需要的。它应该增加相应列的输入元素的大小,以便能够在不滚动数据的情况下输入大约35个字符。禁止输入超过45个字符。您可能需要增加Edit/Add form参数的默认值300,以便在不进行水平滚动的情况下显示表单的所有输入元素

不应对长标签进行其他设置。表格位于表格上,自动增加列宽

已更新:您可以对父
使用
显示:内联块
,它包含由
自定义\u元素返回的HTML片段
。下面的代码

function combobox_element(value, width) {
    var elemStr = '<div>' +
                  '<input class="FormElement ui-widget-content ui-corner-all" ' +
                  'style="vertical-align:top;width:' +  width + 'px" value="' +
                  value + '"/>' +
                  '<button class="ui-widget-content ui-corner-right ui-button-icon"' +
                  ' style="height:22px;width:22px;" tabindex="-1" /></div>',
        newel = $(elemStr)[0];

    setTimeout(function () {
        $(newel).parent().css({display: "inline-block"})
                .parent().css({'padding-bottom': 0});
        $('input:first', newel).autocomplete({
            source: 'Grid/GetLookupList'
        });

        $("button", newel).button({
            icons: { primary: 'ui-icon-triangle-1-s'},
            text: false
        });
    }, 50);

    return newel;
}
函数组合框\元素(值、宽度){
var elemStr=''+
'' +
'',
newel=$(elemStr)[0];
setTimeout(函数(){
$(newel).parent().css({display:“inline block”})
.parent().css({'padding-bottom':0});
$('input:first',newel).自动完成({
来源:“Grid/GetLookupList”
});
$(“按钮”,newel)。按钮({
图标:{primary:'ui-icon-triangle-1-s'},
文本:false
});
}, 50);
返回纽埃尔;
}
将产生


您将看到相应的演示。

谢谢。这不适用于自定义_元素。如何仅在表单编辑/添加模式下增加自动完成组合文本输入元素的宽度?我更新了这个问题,并提供了代码样本。非常感谢。您的解决方案还可以在内联编辑模式下更改输入宽度。如何仅在表单中增加输入宽度,而不是在内联编辑中增加输入宽度?@Andrus:您可以在
自定义元素
功能中设置内联编辑的宽度,并调整
预览前表单
预览后表单
的内部宽度进行表单编辑。谢谢。ColModel被定义为
{name:“WideComboInEdit,edittype:custom,editoptions:{size:54,custom_元素:function(value,options){return combobox_元素(value,options,'17','Tululiik2_nimetus','Summak','Tululik')},custom_值:combobox_值},可编辑:true,宽度:39},
如何强制文本元素在表单编辑/仅添加中使用指定的大小:54?当前大小:54被忽略。宽度:39也在表单中使用。创建jquery setter为组合中的输入元素分配大小值是合理的吗?@Andrus:检测
自定义\u元素内部编辑模式的最简单方法是检查
options
。如果
options.id==options.name
我们处于表单编辑模式(请参阅)。在内联编辑模式下,
options.id
将被构造为
rowid+'.'+options.name
(请参阅),所以
options.id!==options.name
。谢谢。这不适用于自定义元素。如何仅在表单编辑/添加模式下增加“自动完成”组合文本输入元素的宽度?我更新了有关此和pro的问题