select 相关问题

Select是用于查询数据的常用关键字。 'select()'也是一个编程函数,用于根据文件句柄或其他系统活动触发代码。不要将此标记用于以下问题:HTML <select>标记(使用[html-select]);语言集成查询,如LINQ或类似等。

如何在 shadcn ui 中重置选择选项的选定值

我想在提交选择其他产品后重置所选值。 我明确指出从中给出值,任何输入为空但选择选项将保留在所选值上 我想在提交选择其他产品后重置所选值。 我明确表示从中给出值,任何输入为空但选择选项都保留在所选值上 <Select onValueChange={(value) => setSelected({ ...selected, [key]: value }) } > <SelectTrigger className="w-full px-0 h-[16px] text-[13px] border-none"> <SelectValue placeholder={"select"} /> </SelectTrigger> <SelectContent> {productsList[key].map((item, index) => ( <SelectItem key={index} value={item} className={`text-[12px] text-[#040714] p-1 `} > {item} </SelectItem> ))} </SelectContent> </Select> const cancelHandler = () => { setSelected({}); }; <Button variant="ghost" disabled={!disalbleBtns} className="p-0 h-6" onClick={() => submitHandler()} > <SubmitSvg /> </Button> 你应该这样做: 在 FormField 中一起使用 valu 和 defaultValue 在提交后使用form.reset(defaultValues),如下所示: import { zodResolver } from "@hookform/resolvers/zod"; import { SubmitErrorHandler, SubmitHandler, useForm } from "react-hook-form"; import * as z from "zod"; import { Button } from "@/components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { toast } from "@/components/ui/use-toast"; const FormSchema = z.object({ email: z .string({ required_error: "Please select an email to display.", }) .email(), }); const defaultValues = { email: "", }; export function SelectForm() { const form = useForm<z.infer<typeof FormSchema>>({ resolver: zodResolver(FormSchema), defaultValues, }); const onSubmit: SubmitHandler<z.infer<typeof FormSchema>> = (data) => { toast({ title: "You submitted the following values:", description: ( <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> <code className="text-white">{JSON.stringify(data, null, 2)}</code> </pre> ), }); form.reset(defaultValues); }; const onError: SubmitErrorHandler<z.infer<typeof FormSchema>> = (data) => { console.log(data, "error"); toast({ title: "You have error:", description: ( <pre className="mt-2 w-[340px] rounded-md bg-red-700 p-4"> {data.email?.message} </pre> ), }); }; return ( <Form {...form}> <form onSubmit={form.handleSubmit(onSubmit, onError)} className="w-2/3 space-y-6" > <FormField control={form.control} name="email" render={({ field }) => ( <FormItem> <FormLabel>Email</FormLabel> <Select onValueChange={field.onChange} value={field.value} defaultValue={field.value} > <FormControl> <SelectTrigger> <SelectValue placeholder="Select a verified email to display" /> </SelectTrigger> </FormControl> <SelectContent> <SelectItem value="[email protected]">[email protected]</SelectItem> <SelectItem value="[email protected]">[email protected]</SelectItem> <SelectItem value="[email protected]">[email protected]</SelectItem> </SelectContent> </Select> <FormMessage /> </FormItem> )} /> <Button type="submit">Submit</Button> </form> </Form> ); }

回答 0 投票 0

JPA 将查询中选定的 OneToMany 列表作为投影结果中的单个 Java 对象返回

我有与这个问题类似的设置,即一个作者可以有多个评论。在我的例子中,它在 Author 类上被建模为 OneToMany。 @实体 公共课作者{ @ID @

回答 1 投票 0

Laravel Eloquent 选择 CASE?

有没有 PHP 和 Laravel Eloquent 经验的人可以帮助我解决这个问题?我试图在 raw() 方法中注入一个 CASE...WHEN..END... 。看起来很复杂...

回答 4 投票 0

在 SQLite 中将列中的所有值选择为字符串?

在 SQL Server 中,我可以在 Cursor 的帮助下完成此操作(循环遍历结果集中的每一行并构建我的字符串)。但我不知道如何在 SQLite 中做同样的事情,这个任务不像那么...

回答 2 投票 0

Sql 中 FROM 不应该出现在 SELECT 之前吗?

这是我一直困扰的事情。将 FROM 子句放在 SELECT 之前不是更有意义吗?每当我编写 sql 时,尤其是使用连接时,我总是会找出 FROM

回答 2 投票 0

返回所有重复行

我编写了这段代码来查找重复项,它工作得很好: 选择 * 来自样式表 按颜色分组 计数(*) > 1 问题是,它只返回重复行之一。是吗

回答 4 投票 0

根据当前表列的值,从sql中获取另一个表的数据

我正在尝试编写一个 SQL 查询来列出所有用户以及供应商信息。 在 tbl_users 表中,列供应商类型只能有公司或机构,我正在存储

回答 1 投票 0

SQL - 选择多个最小值

我有SQL查询: SELECT min(m.密度), m.金属名称 FROM 金属 m INNER JOIN 存储 s ON m.id = s.metal_id 按 m.metal_name 分组; 结果我得到: +------------+--------------+ | m.密度|米.

回答 1 投票 0

laravel livewire 如果选择的选项是其他则添加动态输入

order.blade.php(步骤组件) order.blade.php (step component) <div class="mt-2"> <x-input-label for="category" :value="__('Category')" /> <x-input-select wire:model.change="state.category" :options="$categories" name="category" id="category" class="block mt-1 w-full" /> <x-input-error :messages="$errors->get('category')" class="mt-2" /> @if($selectedState === '6') <x-input-label for="others" :value="__('Specify category')" /> <x-text-input wire:model="state.others" id="others" class="block mt-1 w-full" name="others" :value="old('others')" /> <x-input-error :messages="$errors->get('others')" class="mt-2" /> @endif </div> Order.php public function updatedStateCategory($name, $value) { // Something you want $this->selectedState = $name; } 如果选择其他选项,则显示文本输入,但刷新或提交表单时,输入消失 selectedState必须在渲染视图之前预设: public function render() { $this->selectedState = $this->state['category']; return view(/* your view */); }

回答 1 投票 0

从客户表中选择订单数最多的前 3 个客户,并从订单表中获取每个客户的总和

客户表 顾客表 订单表 订单表 我想选择订单数最多的前 3 位客户以及每个客户 ID (custid) 的订单总数 我试过这个 选择 c.

回答 1 投票 0

如何在 XSL 属性中填充 id 及其值 <ParentElement id="abc:efg:id:hij:12345.111111.0">

如何在 XSL 属性中填充 id 及其值? 在将源 xml 转换为目标 xml 的过程中。需要有XSL文件。谁能帮助我进行 XSLT 转换? 如何在 XSL 属性中填充 id 及其值? 在将源 xml 转换为目标 xml 的过程中。需要有XSL文件。谁能帮助我进行 XSLT 转换? <xsl:template match="ParentElement/Number"> <xsl:element name="ParentElement"> <xsl:value-of select="substring(.,1,15)"/> <xsl:apply-templates/> </xsl:element> </xsl:template> 我已经尝试过上面的代码片段。 实际输出:12345.111111.0 只需使用: <xsl:template match="ParentElement/Number"> <xsl:element name="ParentElement"> <xsl:attribute name="id"> <xsl:value-of select="substring(.,1,15)"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> 如果没有看到你的 XML,很难判断,但也许你想要类似的东西: <xsl:template match="ParentElement/Number"> <ParentElement id="abc:efg:id:hij:{substring(.,1,15)}"/> <xsl:apply-templates/> </ParentElement> </xsl:template>

回答 2 投票 0

过去 24 个月的记录 - 按月需要从 SQL Server 获取

我有一个员工表,我需要从指定月份开始按月获取过去两年的员工总数。 桌子设计 +------------+-------------+ |领域 | ...

回答 1 投票 0

Antd 选择值标签

我的状态只有 id 来加载选择 //ComponentDidMount方法 让country_data =等待axios.get('/api/v1/countries/'); country_data.data.map((数据) => { 国家.推(<

回答 2 投票 0

如何在同一张表上使用不同的变量创建多级选择stmt

*** 通过评论或下面添加了评论和示例 感谢您的回复! 首先,我对 SQL 还比较陌生。我的任务是从库存表中创建拉取数据。请注意

回答 1 投票 0

<div>带显示:内联网格和<select multiple>内部控件未对齐[重复]

我正在尝试创建一个双重列表来包含/排除项目,但我遇到了一个无法识别的问题。 我有 3 个 div,它们必须彼此相邻显示:第一个带有“incl...

回答 1 投票 0

如何通过在WPF组合框中键入键盘字母键来选择项目?

我有一个 WPF 组合框,当我键入该字母时,我想转到组合框中以(例如)“e”开头的项目。如何? 我的 XAML 代码: 我有一个 WPF ComboBox,当我键入该字母时,我想转到 ComboBox 中以(例如)“e”开头的项目。怎么办? 我的XAML代码: <ComboBox ItemsSource="{Binding Roles}" SelectedValuePath="Id" ItemTemplate="{StaticResource ComboBoxDisplayName}" SelectedItem="{Binding SelectedRole}" Width="150"/> 编辑:我猜你有一个ItemTemplate,看起来有点像这样: <StackPanel> <TextBlock Text="{Binding Path=Foo}" /> <TextBlock Text="{Binding Path=Bar}" /> </StackPanel> 如果您想搜索 Foo,请尝试... <ComboBox IsEditable = "True" TextSearch.TextPath = "Foo" /> 默认情况下,ComboBox有一种自动完成功能,可以根据第一个字母查找匹配项 - 假设您的源按字母顺序排序,这会将所选项目移动到(例如)以“e”开头的部分。 如果您希望有多个以同一字母开头的条目,则捕获 KeyDown 强制打开下拉菜单可能会很有用。 假设您的项目按字母顺序排序,只需设置 IsTextSearchEnabled="True" 即可跳转到以您在 ComboBox 中输入的字母(或多个字母)开头的项目。 这是我的 ComboBox 之一的示例,我简化了绑定,因为它显然不是这里的重要部分... <ComboBox ItemsSource="{Binding MyObjectList}" DisplayMemberPath="Description" SelectedValuePath="Code" IsTextSearchEnabled="True"/> 这非常适合从列表中选择一个值,但是,您键入的搜索值不会显示在控件的 TextBox 部分中,因为我将 IsEditable 设置为 false。 如果有人想解释为什么这被否决,我将不胜感激,我不认为我提供的答案有任何问题,也不明白为什么当我只是想这样做时我应该失去声誉帮助(并提供了合理的答案!) 我所要做的就是添加以下内容: TextSearch.TextPath="<what ever you bound to goes here> ie:State or name " 我知道这是一篇旧帖子,但这可能会对某人有所帮助。 如果您正在使用绑定(您应该这样做)以及 ItemSource 和 SelectedItem,那么只需添加 TextSearch.TextPath="您的绑定显示属性" 正如@mwolff 所述即可正常工作。 <ComboBox Grid.Row="2" Grid.Column="0" Height="25" VerticalContentAlignment="Center" HorizontalAlignment="Center" Width="150" ItemsSource="{Binding EquipmentTypes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedEquipmentType,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Equipment_Type_ID" TextSearch.TextPath="Equipment_Type_Code" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ComboBox.Resources> <Style TargetType="Popup"> <Setter Property="Width" Value="155"/> </Style> </ComboBox.Resources> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Equipment_Type_Code}" TextWrapping="NoWrap" /> </DataTemplate> </ComboBox.ItemTemplate>

回答 4 投票 0

MS Access 查询比较上一行的值

有没有办法比较From和to,看看FROM是否小于之前的TO值? 像这样 从 到 结果 0 1 好的 0.5 2 错误 2 3 好的 3.1 4 好的 3.25 4.9 错误 4.11 5 好的 这是在 Q...

回答 1 投票 0

Javascript下拉/选择,聚焦值(未选择)

JS 有没有办法在 中获取 的值... 这是: 当前聚焦(我的意思是选择已打开,并且该选项通过鼠标悬停来着色, JS有没有办法,在<SELECT>中,获取<OPTION>的值... 即: 当前聚焦(我的意思是选择已打开,并且该选项通过鼠标悬停或键盘使用(通过箭头选择)来着色, 但未经验证(因此 select 值或 select selectedindex 选项值不是好的答案) 尝试谷歌搜索但没有成功。谢谢你, 你好 LGD 这可能会回答你的问题 const select =document.getElementById('myselect') select.addEventListener("change",()=> {let a = select.value console.log(a) }) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="script.js" defer></script> <title>Document</title> </head> <body> <select name="mselect" id="myselect"> <option value="1">select 1</option> <option value="2">select 2</option> <option value="3">select 3</option> </select> </body> </html>

回答 0 投票 0

Laravel 10 - 根据产品选项表中的商品编号进行复杂的产品搜索

检索到第一个货号后,我只能从查询中获取所有产品的数据。每个产品都有一个“type_id”,用于确定产品选择哪个连接表...

回答 1 投票 0

R:从数据帧中删除一行到新数据帧中的问题

我有一张表格,其中包含样本站点的详细信息(站点 ID、纬度和经度、深度、直径等)。它是机密的,但本质上是这样的: id 位置描述 EASTING ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.