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

Grid row doesn't reflect update

5 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BALA MUKUND
Top achievements
Rank 1
BALA MUKUND asked on 15 Sep 2010, 11:47 PM
Hello all,

I am using the Update Commant Item to perform an in-place edit. The data is successfully saved in the database etc. - but the grid data doesn't refresh automatically once the user clicks "Update" although the database reflects the change. I spent a day trying to figure this out but I am at a loss. Any help would be appreciated. I am pasting my code snippets.

All the columns are generated real-time so one doesn't see any column fields in the ASPX.

Thanks
Bala

<telerik:RadGrid OnUpdateCommand="gridCRMList_UpdateCommand" HeaderStyle-Wrap="false" ShowStatusBar="false" OnNeedDataSource="gridCRMList_NeedDataSource" width="99%" ID="gridCRMList" theme="Outlook" EnableEmbeddedSkins="True" Skin="Outlook" AllowFilteringByColumn="False" AutoPostBackOnFilter="False" runat="server" AllowSorting="True" AutoGenerateColumns="False" AllowPaging="True" PageSize="50" AllowMultiRowSelection="true" ShowGroupPanel="False" ClientSettings-ClientEvents-OnRowDblClick="OpenEdit">                                                         
                    <MasterTableView EditMode="InPlace" AlternatingItemStyle-Wrap="false" ItemStyle-Wrap="false" TableLayout="Fixed" width="100%" AllowMultiColumnSorting="true" Font-Names="Tahoma" Font-Size="11px">                      
                        <PagerStyle Mode="NextPrevAndNumeric" Position="Bottom" AlwaysVisible="true"></PagerStyle>
                    </MasterTableView>                  
                    <ClientSettings EnableRowHoverStyle="True">
                            <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
                        <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"/>
                        <Resizing AllowColumnResize="True" />
                        <ClientEvents OnGridCreated="AdjustGridHeight"></ClientEvents>                      
                    </ClientSettings>
                      
              </telerik:RadGrid>
protected void gridCRMList_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
  
            String strKeyValue = String.Empty;
  
            GridEditableItem editedItem = e.Item as GridEditableItem;            
                          
            iChannel.CRM.Controls.GridView grid = new iChannel.CRM.Controls.GridView();
            String strXml = grid.CreateInPlaceUpdateXml(ref editedItem, String.Concat(Request.QueryString[iChannelConstants.QS_ENTITY].ToString(), "_ID"), ref strKeyValue, Request.QueryString[iChannelConstants.QS_USER_ID]);
  
            if (strXml.Length > 0)
            {
                String strRole = STARSService.getRole(Request.QueryString[iChannelConstants.QS_LOGIN], Request.QueryString[iChannelConstants.QS_KEY]);
                String strXmlTemplate = String.Concat(Request.QueryString[iChannelConstants.QS_ENTITY].ToString(), strRole, iChannelConstants.MODE_GRID.ToUpper());
                String strMessage = STARSService.updateEntity(strKeyValue, strXml, strXmlTemplate, Request.QueryString[iChannelConstants.QS_LOGIN], Request.QueryString[iChannelConstants.QS_KEY]);
  
                if (strMessage.Contains(iChannelConstants.SUCCESS))
                {
                    RadGrid outerGrid = editedItem.OwnerTableView.OwnerGrid;
                    outerGrid.Rebind();
                }
  
            }
  
        }

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 20 Sep 2010, 04:01 PM
Hello,

Try removing the line for the explicit grid rebind and see if it makes any difference. Note that the grid is implicitly rebound after update. If you want to rebind it implicitly, then you will need to cancel the default command (e.Canceled = true;).

Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
BALA MUKUND
Top achievements
Rank 1
answered on 20 Sep 2010, 04:17 PM
if (strMessage.Contains(iChannelConstants.SUCCESS))
                {                    
                    e.Canceled = false;
                }
                else
                    e.Canceled = true;

Hello,

I changed it to the above. - still doesn't reflect the change in the grid.

Thanks
Bala
0
Iana Tsolova
Telerik team
answered on 21 Sep 2010, 10:37 AM
Hello,

If you cancel the command, you need to rebind the grid. So you can either cancel the command and rebind or not to call any of them:

if (strMessage.Contains(iChannelConstants.SUCCESS)) 
{                     
    e.Canceled = false;
else
     e.Canceled = true;
       RadGrid outerGrid = editedItem.OwnerTableView.OwnerGrid;
       outerGrid.Rebind();
}


Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
BALA MUKUND
Top achievements
Rank 1
answered on 21 Sep 2010, 04:08 PM
Hello,

I tried both and these are my results

1 - e.Canceled = false;
The change isn't reflected. The grid goes back to read-only mode (like the way it was before)

2 - e.Canceled = true + rebind
The change isn't reflected and the grid stays in edit mode.

Does the update call the Needdatasource event?

Thanks
Bala
0
BALA MUKUND
Top achievements
Rank 1
answered on 21 Sep 2010, 05:26 PM
Thanks all - I was able to resolve this. I was using old data on the Needdatasource event which is why it wasn't working.

Thanks once again.
Bala
Tags
Grid
Asked by
BALA MUKUND
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
BALA MUKUND
Top achievements
Rank 1
Share this question
or