This is a migrated thread and some comments may be shown as answers.

[Solved] Grouping with textbox for ordering

2 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 07 Apr 2009, 07:00 PM
I have a RadGrid with grouping turned on.  I have a templated column with a textbox for entering the order number (position) for reordering and a hidden linkbutton.  I have tied the onkeydown() to click() the hidden linkbutton when the keyCode is 13.  This works fine BUT the group that I am in collapses.  Is there any way to override or bypass the group expand/collapse on pressing enter?

<tlrk:GridTemplateColumn HeaderText="Order" UniqueName="Rank">
    <ItemTemplate>
        <asp:TextBox ID="txtRank" runat="server" Enabled="true" onkeydown="if (event.keyCode==13) $get(this.id.replace('txtRank','') + 'lnkSubmitRank').click();" Text="" Visible="true" Width="20px" />
        <asp:LinkButton ID="lnkSubmitRank" runat="server" style="display:none" OnClientClick="alert('Move To: ' + $get(this.id.replace('lnkSubmitRank','') + 'txtRank').value); event.cancelBubble=true;" />
    </ItemTemplate>
</tlrk:GridTemplateColumn>

 

 

NOTE:

ClientSettings-ClientEvents-OnGroupCollapsed

 

 

does not fire.

Thanks in advance,
Doug

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2009, 06:52 AM
Hi Doug,

I guess a server side postback is taking place on clicking the enter key which is making the Grouped items in the Grid to get collapsed. Here is a codelibrary submission which explains how to  Persist Groups Expanded State on Rebind. Go through it and see if it helps.
Persist Groups Expanded State on Rebind

Thanks
Shinu

0
Doug
Top achievements
Rank 1
answered on 08 Apr 2009, 03:43 PM
You are correct it is a server postback.  I can easily override the postback by setting the e.Canceled = true in the gv_ItemCommand if the postback is due to a reorder.  I still have an issue with the postback happening.  Using fiddler I see that I am getting two simultaneous postbacks.  The render is based on the canceled expand/collapse postback so my data view is incorrect.  The sort works correctly (checking the database) but the data rendered is incorrect.  I bind in the lnk_click postback.  If I bind in the ItemCommand postback the data renders correctly, but I am afraid that I have created a race situation here.  Plus it is just plain waisting bandwidth.

Long-short of it, can I stop the ItemCommand(ExpandCollapse) postback from happening on clicking enter?

Thanks,
Doug
Tags
Grid
Asked by
Doug
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Doug
Top achievements
Rank 1
Share this question
or