Hidding "InitInsert" button when in edit mode

4 posts, 0 answers
  1. Pako
    Pako avatar
    16 posts
    Member since:
    Oct 2010

    Posted 15 Apr 2011 Link to this post

    Hi,

    I'm trying to accomplish this: I need to hide my "Add own content" buttons when user enters Insert mode. To handle this, I subscribed ItemCommand event and check if CommandName is "InitInsert". If is, I set EventSource element visibility to false. That works great.

    What's giving me hard time is EmptyDataTemplate. I placed my "Add own content" button in this template, but then after clicking it, layout changes, so of course setting visibility of this button to false have no meaning. I figured out, that I could handle LayoutCreated event and then find this button and hide it. There I encountered another problem: how to find out, whether I'm in Insert mode or not? InsertItem property of ListView is null, when I know that I entered insert mode. I looked through other properties and cannot seem to find out how to verify mode in which ListView is.

    My question are:

    1. How can I find out whether I'm in insert mode or not?

    2. Is there any other way I can hide "add own content' button when in insert mode?

    Thanks in advance,

    Pako

  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 20 Apr 2011 Link to this post

    Hi Pako,

    Check how the "Add new product" is displayed fonditionally in this demo and see if you can use the same approach.
    And to find a control in RadListView, you can try using the FindControl() method. For more information on how to access conrols in RadListView, refer to this topic.

    All the best,
    Iana
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pako
    Pako avatar
    16 posts
    Member since:
    Oct 2010

    Posted 20 Apr 2011 Link to this post

    Like I said, for some reason InsertItem is nothing when InitInsert command is called (at least when LayoutCreated event is raised), so I cannot use this approach. InsertItemPosition also is None at this moment.

    I used workaround for this issue, using attributes collection of list view to remember whether listview is in Insert mode or not, but I'm aware, that this is not the right approach and would like to change it to something like this demo showed.

    I hoped, that maybe you know something about RadListView that's causing InserItem to be null when InitInsert command is called.

  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 26 Apr 2011 Link to this post

    Hello Pako,

    InitInsertCommand is fired before the insert item is displayed/created. That is why then the InsertItem is null and the InsertItemPosition is None. You can use them in the listview PreRender event instead to achieve your goal. Or directly in the layout declaration as in the demo.

    Best wishes,
    Iana
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top