以编程方式创建多列 radcombobox

发布于 2024-12-14 15:14:13 字数 58 浏览 1 评论 0原文

任何人都有代码示例的链接,或者您可以提供一个代码片段来完成此任务。我在 Telerik 网站上显示空白

Anyone have a link to a code sample or can you provide a snippet to accomplish this task. I'm coming up blank on the Telerik site

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮世清欢 2024-12-21 15:14:13

不久前,我不得不将一些东西放在一起,并发现代码片段散布在 Telerik 的网站和博客中。所以,我不想因为创建下面的代码而获得“功劳”...但这就是我正在使用的:

将其添加到您的 css

.rcbHeader ul, .rcbFooter ul, .rcbItem ul, .rcbHovered ul, .rcbDisabled ul
{
    width: 100%;
    display: inline-block;
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.col1, .col2, .col3
{
    float: left;
    width: 100px;
    margin: 0;
    padding: 0 0px 0 0;
    line-height: 14px;
}

如果您想要一个“项目计数器” " 添加此 javascript 函数

function UpdateItemCountField(sender, args) {
        //set the footer text
        sender.get_dropDownElement().lastChild.innerHTML = "A total of " + sender.get_items().get_count() + " items";
    }

这是 RadComboBox 的代码

<telerik:RadComboBox runat="server" ID="rcbInvoiceNumber" Height="190px" Width="350px"
    MarkFirstMatch="true" EnableLoadOnDemand="true" HighlightTemplatedItems="true"
    OnClientItemsRequested="UpdateItemCountField" OnItemDataBound="rcbInvoiceNumber_ItemDataBound"
    OnItemsRequested="rcbInvoiceNumber_ItemsRequested" EmptyMessage="Enter Invoice Number"
    ChangeTextOnKeyBoardNavigation="true" ValidationGroup="QuickPay">
    <HeaderTemplate>
        <ul>
            <li class="col1">Invoice Number</li>
            <li class="col2">PO Number</li>
            <li class="col3">Invoice Total</li>
        </ul>
    </HeaderTemplate>
    <ItemTemplate>
        <ul>
            <li class="col1">
                <%# DataBinder.Eval(Container.DataItem, "InvoiceNumber") %></li>
            <li class="col2">
                <%# DataBinder.Eval(Container.DataItem, "PONumber")%></li>
            <li class="col3">
                <%# DataBinder.Eval(Container.DataItem, "TotalInvoice", "{0:C}")%></li>
        </ul>
    </ItemTemplate>
    <FooterTemplate>
        A total of
        <asp:Literal runat="server" ID="RadComboItemsCount" />
        items
    </FooterTemplate>
</telerik:RadComboBox>

最后是背后的代码

    protected void rcbInvoiceNumber_DataBound(object sender, EventArgs e)
    {
        //set the initial footer label
        ((Literal)rcbInvoiceNumber.Footer.FindControl("RadComboItemsCount")).Text = Convert.ToString(rcbInvoiceNumber.Items.Count);
    }

    protected void rcbInvoiceNumber_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        var invs = new VInvoicesCasesTotalCollection()
            .Load();

        rcbInvoiceNumber.DataSource = invs.ToDataTable();
        rcbInvoiceNumber.DataBind();
    }

    protected void rcbInvoiceNumber_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
    {
        //set the Text and Value property of every item
        //here you can set any other properties like Enabled, ToolTip, Visible, etc.
        e.Item.Text = ((DataRowView)e.Item.DataItem)["InvoiceNumber"].ToString();
        e.Item.Value = ((DataRowView)e.Item.DataItem)["InvoiceID"].ToString();
    }

应该注意的是,我已将 Telerik.Web.UI 添加到我的使用语句。

希望这至少可以帮助您朝着正确的方向前进。

I had to put something together a while ago and found snippets of code scattered throughout Telerik's site and blogs. So, I don't want to take "credit" for creating the below code... but here's what I'm using:

Add this to your css

.rcbHeader ul, .rcbFooter ul, .rcbItem ul, .rcbHovered ul, .rcbDisabled ul
{
    width: 100%;
    display: inline-block;
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.col1, .col2, .col3
{
    float: left;
    width: 100px;
    margin: 0;
    padding: 0 0px 0 0;
    line-height: 14px;
}

If you want an "item counter" add this javascript function

function UpdateItemCountField(sender, args) {
        //set the footer text
        sender.get_dropDownElement().lastChild.innerHTML = "A total of " + sender.get_items().get_count() + " items";
    }

Here's the code for the RadComboBox

<telerik:RadComboBox runat="server" ID="rcbInvoiceNumber" Height="190px" Width="350px"
    MarkFirstMatch="true" EnableLoadOnDemand="true" HighlightTemplatedItems="true"
    OnClientItemsRequested="UpdateItemCountField" OnItemDataBound="rcbInvoiceNumber_ItemDataBound"
    OnItemsRequested="rcbInvoiceNumber_ItemsRequested" EmptyMessage="Enter Invoice Number"
    ChangeTextOnKeyBoardNavigation="true" ValidationGroup="QuickPay">
    <HeaderTemplate>
        <ul>
            <li class="col1">Invoice Number</li>
            <li class="col2">PO Number</li>
            <li class="col3">Invoice Total</li>
        </ul>
    </HeaderTemplate>
    <ItemTemplate>
        <ul>
            <li class="col1">
                <%# DataBinder.Eval(Container.DataItem, "InvoiceNumber") %></li>
            <li class="col2">
                <%# DataBinder.Eval(Container.DataItem, "PONumber")%></li>
            <li class="col3">
                <%# DataBinder.Eval(Container.DataItem, "TotalInvoice", "{0:C}")%></li>
        </ul>
    </ItemTemplate>
    <FooterTemplate>
        A total of
        <asp:Literal runat="server" ID="RadComboItemsCount" />
        items
    </FooterTemplate>
</telerik:RadComboBox>

Finally, the code behind

    protected void rcbInvoiceNumber_DataBound(object sender, EventArgs e)
    {
        //set the initial footer label
        ((Literal)rcbInvoiceNumber.Footer.FindControl("RadComboItemsCount")).Text = Convert.ToString(rcbInvoiceNumber.Items.Count);
    }

    protected void rcbInvoiceNumber_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        var invs = new VInvoicesCasesTotalCollection()
            .Load();

        rcbInvoiceNumber.DataSource = invs.ToDataTable();
        rcbInvoiceNumber.DataBind();
    }

    protected void rcbInvoiceNumber_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
    {
        //set the Text and Value property of every item
        //here you can set any other properties like Enabled, ToolTip, Visible, etc.
        e.Item.Text = ((DataRowView)e.Item.DataItem)["InvoiceNumber"].ToString();
        e.Item.Value = ((DataRowView)e.Item.DataItem)["InvoiceID"].ToString();
    }

It should be noted that I've added Telerik.Web.UI to my using statements.

Hopefully this at least helps steer you in the right direction.

心凉怎暖 2024-12-21 15:14:13

我已经看过此页面上的链接,并在他们的页面上寻找答案,因为我确信我以前见过它。

clk 帖子评论部分中提到的链接确实是一个演示,但如果您想要基础知识并且很可能是最简单的文档,可以找到它 此处。

正如您提到的,您正在后面的代码中加载数据,所以您可以做的是首先加载实体,接下来设置数据源,然后然后继续按照页面加载中我的链接文章代码的其余部分进行操作。

希望它能有所帮助,哪怕是一点点。

I've seen the links on this page and went in search of the answer on their page, becasue I was sure I had seen it before.

The link to mentioned in the comment section of clk's post is indeed a demo, but if you want the basics and quite possibly the easiest documentation to look at it would be found here.

As you mention you are loading you data on the code behind, so what you could do is load the entities first, set the data source next, and then continue to follow the rest of my linked articles code in the page load.

Hope it helps even a little.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文