我需要帮助使用find或get或其他任何东西在键值对中获取两个值(用于人类友好下拉列表).我需要帮助最简单的方法在CakePHP中执行此操作.
这是我的尝试:
在我的控制器中
$users = $this->LocationsUser->Users->find('list', [
'limit' => 1,
'keyField' => 'id',
'valueField' => ['first_name', 'last_name']
])->where(['id' => $id]);
Run Code Online (Sandbox Code Playgroud)在我看来
echo $this->Form->input('user_id', [
'options' => $users,
'type' => 'select',
'multiple' => false,
]);
Run Code Online (Sandbox Code Playgroud)我下拉列表的结果:
<option value="10">Fabian;Pankiers</option>
Run Code Online (Sandbox Code Playgroud)看到我需要一个没有分号的结果";" .现在我可以使用javascript删除分号,但那就太过分了.在CakePHP 3中有没有一种简单的方法可以实现这一点?
实际上我知道选择框width是由列表中最长的选项设置的,但我想增加selecthtml元素的长度(宽度).
我也搜索过,我理解这段代码style="max-width:70%"可能有用,但它对我不起作用.
我的代码是我的:
<select class="form-control"style="max-width:70%">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Run Code Online (Sandbox Code Playgroud) 我在本地 json 中有一个国家名称列表。我可以加载我的本地 json 并分配给DropDown button。json 文件中有 193 个国家/地区,例如。如下所示。如果我想选择美国,用户必须一直向下滚动。如何输入国家名称,例如;如果我用户输入 U 或 u,下拉菜单可以进行快速过滤并列出所有以 U 开头的国家/地区,例如美国。如何在 Flutter DropDownbutton 项目中搜索?
{
"country": [
{
"countryCode": "AD",
"countryName": "Andorra",
"currencyCode": "EUR",
"isoNumeric": "020"
},
{
"countryCode": "AE",
"countryName": "United Arab Emirates",
"currencyCode": "AED",
"isoNumeric": "784"
},
{
"countryCode": "AF",
"countryName": "Afghanistan",
"currencyCode": "AFN",
"isoNumeric": "004"
},
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作两个下拉菜单.这些是我的数据库中的国家/地区和州选择.我的问题是不知道如何制定国家必须依赖国家的条件.当我选择[countryname]时,它会在我的下拉列表中给出不同的州名称选择.到目前为止我到目前为止所做的工作.
AdminController.php
public function user_register()
{
$countryname = DB::table('countries')
->get();
$statename = DB::table('states')
->get();
$title = ucwords(Lang::get('constants.user') . ' ' . Lang::get('constants.register'));
return View::make('register.user_register')
->with('title', $title)
->with('page', 'user_register')
->with('countryname', $countryname)
->with('statename', $statename)
}
Run Code Online (Sandbox Code Playgroud)
user_register.blade.php
<select class="form-control" id="countries" name="countries">
<option value="">Please select</option>
<?php foreach ($countryname as $key=>$countryname): ?>
<option value="<?php echo $countryname->sortname; ?>"<?php
if (isset($countries) && Input::old('countries') == $countryname->sortname)
{
echo 'selected="selected"';
}
?>>
<?php echo $countryname->sortname ." - ". $countryname->name ; ?>
</option>
<?php endforeach; ?>
</select>
<select class="form-control" id="states" …Run Code Online (Sandbox Code Playgroud) DropdownMenuItems的默认DropdownButton返回浅灰色下拉列表.我应该如何自定义下拉列表(例如背景颜色,下拉宽度)?我可以style在DropdownButton和DropdownMenuItem中更改属性,如下所示:
return new DropdownButton(
value: ...,
items: ...,
onChanged: ...,
style: new TextStyle(
color: Colors.white,
),
);
Run Code Online (Sandbox Code Playgroud)
但这不会改变下拉列表的背景颜色.
我应该复制DropdownMenu并扩展吗?Flutter是否计划在不久的将来为此小部件添加自定义?
我有使用 PrimeNg p-dropdown 的组件。
html代码:
<p-dropdown [style]="{'width':'150px'}" [options]="portNames" placeholder="Select a Port">
</p-dropdown>
Run Code Online (Sandbox Code Playgroud)
ts portNames 声明:
portNames: string[] =["Port 01","Port 02", "Port 03"];
Run Code Online (Sandbox Code Playgroud)
我的问题是 DropDown 不显示值“端口 01”、“端口 02”、“端口 03”。
也许我有什么错误?
我正在从 JSON 获取项目并将它们显示在下拉列表中。当这个人从下拉列表中选择一个项目时,我得到了选择,但所选项目没有改变。
例如,我们在列表中有 (tokyo, paris, new york)。默认选择是东京。当这个人选择巴黎时,我明白了,但下拉列表中的选择没有改变。
这是我的代码:
new DropdownButton(
value: cities.elementAt(0),
hint: new Text("Ville"),
items: cities.map((String value) {
return new DropdownMenuItem(
value: value,
child: new Row(
children: <Widget>[
new Icon(
Icons.location_city,
color: Colors.deepOrange,
),
new Text(value)
],
),
);
}).toList(),
onChanged: (String value) {
getTravelCity(value);
},
),
Run Code Online (Sandbox Code Playgroud)
当人选择一个项目时,它仍然显示默认值。
例如,我有这样的事情:
通过以下 HTML 代码,我将整个下拉列表的最大宽度设置为 80%,我希望这会影响每个选项。
我希望拥有它,以便长选项在最大点处环绕:
红线表示什么被视为“一个选项”,因此当我将鼠标悬停在其上时,应选择红线之间的所有内容
<select name=countries style="width:100%;max-width:30%;">
<option value=gs selected="selected">All</option>
<option value=gs>This is fine</option>
<option value=gs>This message should wrap because it is very long</option>
<optgroup label="Title">
<option value="optcheck">Option groups are long, so they should wrap too</option>
</optgroup>
</select>
Run Code Online (Sandbox Code Playgroud)
我创建了一些DropDownLists,它们填充了数据库中的数据.下拉列表的第一行是ListItem:
<asp:DropDownList ID="ddlChange_Requestor" runat="server" AppendDataBoundItems="True" CssClass="ddlChange_Requestor">
<asp:ListItem>Change Requestor</asp:ListItem>
Run Code Online (Sandbox Code Playgroud)
我还有一个GridView,它在Select按钮上有一个RowCommand事件.
当我按下SelectDropDownLists时,将获得所尊重的列/行所具有的任何值:
protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
{
{
GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);
txtActivity.Text = row.Cells[2].Text;
ddlChange_Requestor.SelectedValue = row.Cells[10].Text;
}
}
Run Code Online (Sandbox Code Playgroud)
当GridView中的Change Request列/行具有值但不是"white-space"/"Empty"/"Null"时,这种方法有效.我真的不知道如何解决它?
我希望能够做到这样的事情:
ddlChange_Requestor.SelectedValue = isnullOrwhitespace(row.Cells[10].Text , "Change Requestor");
Run Code Online (Sandbox Code Playgroud)
但是我只想在后台使用它,因为我想在GridView中有空行但在RowCommand上Select应该理解空ListItem值意味着值.
这可能吗?
可能导致此错误的任何想法?
我的清单包括:
<link rel="stylesheet" href="../../node_modules/semantic-ui/dist/semantic.min.css">
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="../../node_modules/fullcalendar/dist/fullcalendar.min.css">
<script src="../../node_modules/semantic-ui/dist/semantic.min.js"></script>
<script src="../../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../../node_modules/moment/min/moment.min.js"></script>
<script src="../../node_modules/fullcalendar/dist/fullcalendar.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
HTML元素:
<div class="ui floating dropdown labeled search icon button" style="width: 95%; margin: 0 auto;" id="monthDrop">
<i class="calendar icon"></i>
<span class="text">Choose a Month</span>
<div class="menu">
<div class="item">January</div>
<div class="item">February</div>
<div class="item">March</div>
<div class="item">April</div>
<div class="item">May</div>
<div class="item">June</div>
<div class="item">July</div>
<div class="item">August</div>
<div class="item">September</div>
<div class="item">October</div>
<div class="item">November</div>
<div class="item">December</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本:
$('#monthDrop').dropdown();
Run Code Online (Sandbox Code Playgroud)
它渲染得很好,一切都没有加载错误,就在我尝试点击它时:
dropdown ×10
flutter ×3
dart ×2
html ×2
angular ×1
asp.net ×1
bootstrap-4 ×1
c# ×1
cakephp ×1
cakephp-3.0 ×1
css ×1
database ×1
filtering ×1
find ×1
gridview ×1
html-select ×1
javascript ×1
key-value ×1
laravel ×1
mysql ×1
php ×1
popper.js ×1
primeng ×1
rowcommand ×1
semantic-ui ×1
widget ×1