EasyUi的Combobox如何选中某项值?
$('#combo').combobox('select','菜单项');用这句代码,可以选中combobox中的某一项值但是combobox中的数据如果是对象,用上面这...
$('#combo').combobox('select','菜单项');
用这句代码,可以选中combobox中的某一项值
但是combobox中的数据如果是对象,用上面这句代码就选不中了
要怎么才能选中对象呢?
[{
"id":1,
"text":"text1"
},{
"id":2,
"text":"text2"
}]
$('#cc').combobox({
url:'combobox_data.json',
valueField:'id',
textField:'text'
}); 展开
用这句代码,可以选中combobox中的某一项值
但是combobox中的数据如果是对象,用上面这句代码就选不中了
要怎么才能选中对象呢?
[{
"id":1,
"text":"text1"
},{
"id":2,
"text":"text2"
}]
$('#cc').combobox({
url:'combobox_data.json',
valueField:'id',
textField:'text'
}); 展开
2个回答
展开全部
1.添加combobox后做如稿核下设置
2.根据自己的需要在类中重写如下方法
// ==========================================================
// Combo box data source methods
// ==========================================================
- (NSInteger) numberOfItemsInComboBox: (NSComboBox *) aComboBox {
#pragma unused (aComboBox)
return ([dataSource count]);
}
- (id) comboBox: (NSComboBox *) aComboBox objectValueForItemAtIndex: (NSInteger) index {
#pragma unused (aComboBox)
return [dataSource objectAtIndex:index];
}
- (NSUInteger) comboBox: (NSComboBox *) aComboBox indexOfItemWithStringValue: (NSString *) string {
#pragma unused (aComboBox)
return [dataSource indexOfObject:string];
}
- (NSString *) firstGenreMatchingPrefix: (NSString *) prefix {
NSString *string = nil;
NSString *lowercasePrefix = [prefix lowercaseString];
NSEnumerator *stringEnum = [dataSource objectEnumerator];
while ( string = [stringEnum nextObject] )
if ([[string lowercaseString] hasPrefix:lowercasePrefix] ) {
return (string) ;
}
return (nil);
} // firstGenreMatchingPrefix
- (NSString *) comboBox: (NSComboBox *) aComboBox completedString: (NSString *) inputString {
#pragma unused (aComboBox)
// This method is received after each character typed by the user, because we have checked the "completes" flag for
// genreComboBox in IB.
// Given the inputString the user has typed, see if we can find a genre with the prefix, and return it as the suggested complete
// string.
NSString *candidate = [self firstGenreMatchingPrefix:inputString];
return (candidate ? candidate : inputString);
}
这些方法实现combobox在选择选项、自动完成时的处理方悄敬数式。其中dataSource为NSArray。
3.设置combobox的datasource为实现上述方法的启首对象即可。
2.根据自己的需要在类中重写如下方法
// ==========================================================
// Combo box data source methods
// ==========================================================
- (NSInteger) numberOfItemsInComboBox: (NSComboBox *) aComboBox {
#pragma unused (aComboBox)
return ([dataSource count]);
}
- (id) comboBox: (NSComboBox *) aComboBox objectValueForItemAtIndex: (NSInteger) index {
#pragma unused (aComboBox)
return [dataSource objectAtIndex:index];
}
- (NSUInteger) comboBox: (NSComboBox *) aComboBox indexOfItemWithStringValue: (NSString *) string {
#pragma unused (aComboBox)
return [dataSource indexOfObject:string];
}
- (NSString *) firstGenreMatchingPrefix: (NSString *) prefix {
NSString *string = nil;
NSString *lowercasePrefix = [prefix lowercaseString];
NSEnumerator *stringEnum = [dataSource objectEnumerator];
while ( string = [stringEnum nextObject] )
if ([[string lowercaseString] hasPrefix:lowercasePrefix] ) {
return (string) ;
}
return (nil);
} // firstGenreMatchingPrefix
- (NSString *) comboBox: (NSComboBox *) aComboBox completedString: (NSString *) inputString {
#pragma unused (aComboBox)
// This method is received after each character typed by the user, because we have checked the "completes" flag for
// genreComboBox in IB.
// Given the inputString the user has typed, see if we can find a genre with the prefix, and return it as the suggested complete
// string.
NSString *candidate = [self firstGenreMatchingPrefix:inputString];
return (candidate ? candidate : inputString);
}
这些方法实现combobox在选择选项、自动完成时的处理方悄敬数式。其中dataSource为NSArray。
3.设置combobox的datasource为实现上述方法的启首对象即可。
2016-08-01
展开全部
$('#combobox).combobox('getValue')
获取当返慧早前选漏雀碧棚中的值$
('#combobox).combobox('getText')
获取当返慧早前选漏雀碧棚中的值$
('#combobox).combobox('getText')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询