简体   繁体   English

将onClick添加到Infragistics WebDataGrid

[英]Add an onClick to an Infragistics WebDataGrid

I have an Infragistics WebDataGrid and I want to fire a server side event every time a cell is clicked on. 我有一个Infragistics WebDataGrid,我想每次单击一个单元格时都触发一个服务器端事件。 I know that I can make a button and add an onclick to that, but I want some or all the data cells to be clickable. 我知道我可以创建一个按钮并向其中添加一个onclick,但是我希望某些或所有数据单元都是可单击的。 I also saw this( https://www.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/108226/onclick-event-for-webdatagrid ) but I need the event to fire server side. 我也看到了这个( https://www.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/108226/onclick-event-for-webdatagrid ),但是我需要事件来触发服务器端。

You can try the following: 您可以尝试以下方法:

  1. Handle "Click" client event and call __doPostBack js function to trigger a postback. 处理“ Click”客户端事件,并调用__doPostBack js函数来触发回发。 Page_Load server event will help you to determine whether the postback is caused by the click or not. Page_Load服务器事件将帮助您确定回发是否是由单击引起的。 Things to consider, client event "Click" will be fired on every click inside the Grid, have a look at the provided API link for more info. 要考虑的事情是,在网格内部的每次点击都会触发客户端事件“点击” ,请查看提供的API链接以获取更多信息。
  2. Activate Selection behavior, and handle CellSelectionChanged client event. 激活选择行为,并处理CellSelectionChanged客户端事件。 From here use the approach with __doPostBack . 从这里开始,使用__doPostBack方法。

The Grid is very powerful control with a rich API and the behaviors, so we could thing of a different way to achieve this. Grid是一个非常强大的控件,具有丰富的API和行为,因此我们可以采用另一种方式来实现这一目标。

Snippet: 片段:

..
<script>
        function client_click(sender, evtArgs) {
            // First Approach
            __doPostBack('myRequest', "someValue");
        }

        function WDG_Selection_CellSelectionChanged(sender, eventArgs)
        {
            // Second Approach
            __doPostBack('myRequest', "someValue");
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
    <div>
        <ig:WebDataGrid runat="server" ID="WDG" AutoGenerateColumns="False" Width="600px">
            <ClientEvents Click="client_click" />
            <Columns>
                <ig:BoundDataField DataFieldName="CategoryId" Key="CategoryId">
                    <Header Text="CategoryId">
                    </Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="CategoryName" Key="CategoryName">
                    <Header Text="CategoryName">
                    </Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="Description" Key="Description">
                    <Header Text="Description">
                    </Header>
                </ig:BoundDataField>
            </Columns>
            <Behaviors>
                <ig:EditingCore>
                    <Behaviors>
                        <ig:CellEditing>
                            <CellEditingClientEvents EnteringEditMode="entering_edit_mode" />
                        </ig:CellEditing>
                    </Behaviors>
                </ig:EditingCore>
                <ig:Selection>
                    <SelectionClientEvents CellSelectionChanged="WDG_Selection_CellSelectionChanged" />
                </ig:Selection>
            </Behaviors>
        </ig:WebDataGrid>


..

c# C#

protected void Page_Load(object sender, EventArgs e)
{
    string parameter = Request["__EVENTARGUMENT"];

... ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将工具提示分配给Infragistics WebDataGrid中所选行的单元格 - Assign Tooltip to cell of selected row in Infragistics WebDataGrid Infragistics WebDataGrid复选框和隐藏列问题 - Infragistics WebDataGrid Checkbox and hidden column problems 在WebDataGrid中获取Infragistics中多列标题的标题行计数 - Getting the Header Rows Count of Multi Column Header in WebDataGrid, Infragistics 如何在 Infragistics WebDataGrid 中为动态添加的列设置格式? - How do I set formatting for a dynamically added column in Infragistics WebDataGrid? infragistics webdatagrid从客户端的keydown事件中获取所选单元格 - infragistics webdatagrid get selected cell from keydown event in client side 如何以编程方式向我的WebDataGrid添加新行 - How to Add new rows programmatically to my WebDataGrid Infragistics WebDataGrid通过列名称从选定的行获取值:VB.net到C#的转换 - Infragistics WebDataGrid get value from a selected row by column name: VB.net to C# conversion 什么是使用Infragistics WebDataGrid和SQL Server 2008进行分页的理想方式 - What would be the ideal way to do paging using a Infragistics WebDataGrid and SQL Server 2008 具有大型数据集的 Infragistics WebExcelExporter.Export(webdatagrid, worksheet) 的性能问题 - Performance issues with Infragistics WebExcelExporter.Export(webdatagrid, worksheet) with large data sets UltraWinGrid Infragistics gui添加列 - UltraWinGrid Infragistics gui add column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM