Ticket Q345193
Visible to All Users

ASP.NET ListView Inline Edit On Row Click (not the button)

created 13 years ago

Hello Support,
I have been scratching my head trying to find a way of overriding the click event in a List View, which by default only gives you the option of navigating to the Detail or Edit views for that record. Ideally I would like to trap the ListViewProcessCurrentObjectController event to ; instead of navigating to the predefined Detail or Edit forms, go straight to in line edit for the row that has just been clicked. This would be the equivalent of clicking on the Grid editor edit icon.
Many Thanks,
Ken

Comments (3)
Dennis Garavsky (DevExpress) 13 years ago

    Hi Ken,
    Thank you for contacting us. I am afraid ASPxGridListEditor does not support this by default. It is intentionally designed to drill into record details on a single click, because it is the default and natural behavior for many Web applications.
    However, XAF is flexible enough and you can customize its default behavior as you require.
    Attached is some example code that I hope will be a good starting point for you:

    C#
    using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Web.Editors.ASPx; namespace Main.Module.Web { public class Q345193 : ViewController<ListView> { private ASPxGridListEditor editor; private ListViewProcessCurrentObjectController processRecordController; protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); if (View.Model.AllowEdit) { editor = View.Editor as ASPxGridListEditor; if (editor != null) { editor.Grid.Load += Grid_Load; processRecordController = Frame.GetController<ListViewProcessCurrentObjectController>(); processRecordController.CustomProcessSelectedItem += processRecordController_CustomProcessSelectedItem; } } } private void Grid_Load(object sender, EventArgs e) { editor.Grid.ClientSideEvents.RowClick = "function(s, e){{s.UnselectRowOnPage(e.visibleIndex);s.StartEditRow(e.visibleIndex);}}"; } protected override void OnDeactivated() { if (editor != null && editor.Grid != null) editor.Grid.Load -= Grid_Load; if (processRecordController != null) processRecordController.CustomProcessSelectedItem -= processRecordController_CustomProcessSelectedItem; base.OnDeactivated(); } private void processRecordController_CustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e) { e.Handled = true; } } }

    To test it in action, add this code into the Main.Module.Web module and be sure to enable AllowEdit for Contact_ListView via the application model.
    Please let me know if this helps.
    See Also:
    http://documentation.devexpress.com/#Xaf/CustomDocument3165
    Thanks,
    Dennis

      Hi Dennis,
      Youre the man! Thanks for your help. Thats exactly what I needed. Now sorted.
      Cheers
      Ken

      Dennis Garavsky (DevExpress) 13 years ago

        Hello Ken,
        Thank you for your reply. I am glad to hear that my assistance was helpful;-)
        Please let us know what you think of our frameworks and other DevExpress products by rating them on the Visual Studio Gallery:
        eXpressApp Framework
        eXpress Persistent Objects
        Thank you for your help!
        Respectfully,
        Dennis

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.