Hi All,
I have an ultrawebgrid with virtual scrolling ajax. I select one record and change in in a modal popup window, then when I return from the modal i would like to trigger a
gridLCN.invokeXmlHttpRequest(gridLCN.eReqType.Refresh,
null, "");
but I want only the current row to be refreshed and not the whole grid. I don't want change cell by cell in grid but trigger a refresh only of that row so I don't lose the scroll position of the grid nor it send me to the first record of the grid.
Any ideas are appreciated.
Hello Federico,
You can specify what kind of request to be issued to the server check that out :
eReqType.UpdateCell - the cell that is being updated;
eReqType.AddNewRow - the rows collection a new row is added to;
eReqType.Sort - the rows collection that is being sorted;
eReqType.ChildRows - the row which child rows are requested;
eReqType.DeleteRow - the row that is being deleted;
eReqType.UpdateRow - the row that is being updated.
eReqType.Filter - the rows collection the filter is being applied to;
eReqType.FilterDropDownFill - the rows collection the filter is being
If you want to issue the request from code running on the child window you can access the parent window through opener.grid.invokeHttpRequest()……
Please refer the client side object model:
http://help.infragistics.com/NetAdvantage/ASPNET/2010.3?page=WebGrid_Object_CSOM.html
Hope this helps.
Hi Rado,
Thank you for your reply.
This is that the that I have a grid with vritual scrolling, ajax, then the user scrolls down and the grid pulls automatically more rows from the server as the user scrolls down, then the user clicks on q templated field "Edit" of a specific row and I open that record in a modal window, then the user changes and saves the record which updates the server. When the user hits the save button I window.close and return to the main screen where the grid is, thing is that I don't want to return the values form the modal window and change the grid row in javascript by changing cell by cell, but instead I would like to trigger a "refresh row" so the grid pulls the updated row from the server and refreshes only that row, in this way I don't lose the current position of the grid and the row gets refreshed.
Would the UpdateRow Method do what I need?, Could you please provide a line with an example of the eReqType.UpdateRow ?
This is my Edit Sub in JavaScript.
function EditLCN_Click() { var row = gridLCN.getActiveRow(); var rowlcn = row.getCellFromKey("Local Composition Number").getValue(); var aLCNArgs = new Array(_txtcurrentuserLCN.Element.value, rowlcn); var currentbackground = document.bgColor; document.bgColor = '#CCCCCC'; var myRand = rand(50000); returnValue = window.showModalDialog('EditLCNv2.aspx?s=' + rowlcn + '&v=a' + '&rand=' + myRand, aLCNArgs, 'resizable=yes;unadorned=no;scroll=yes;status=no;dialogWidth=1008px;dialogHeight=700px;'); document.bgColor = currentbackground; if (returnValue != false) { // _txtoperationsmessage = returnValue; gridLCN.invokeXmlHttpRequest(gridLCN.eReqType.Refresh, null, ""); //but this refreshes the whole grid and makes the grid jump to the first row... } return false; }
Many thanks
Federico.
by the way, basically I use the Grid only to display the rows and let the user select the row, then when he clicks on "Edit" I retrieve the "latest" record from the server, display it on the pop up, then the user changes record, and saves it straight to the server, then closes window and goes back to screen where the grid is, and here is when I would like the grid to retrieve "changed rows" without having the pointer to the current row lost.
fesani said:by the way, basically I use the Grid only to display the rows and let the user select the row, then when he clicks on "Edit" I retrieve the "latest" record from the server, display it on the pop up, then the user changes record, and saves it straight to the server, then closes window and goes back to screen where the grid is, and here is when I would like the grid to retrieve "changed rows" without having the pointer to the current row lost
Federico,
I think I get your point, but if you save all changes directly to the server through PopUp window, there is no way the grid to know what has been changed. When you press save button from the PopUp window do you make a full postback? if yes you could just reload the grid with updated rows when you back to the grid, but in such case you need to take care for the id of selected row in order to select the row by javascript when you bring the grid again with the changes.
I guess that when you show the data from the selected row of the grid in order to be edited you know the index of this row am I correct? if yes you can just update the server through the PopUp and then refresh the grid and set as activeRow the the row that has been updated. You can Activate row on the client like this :
grid.setActiveRow(row) or grid setActiveCell(cell);
More info about the client side api : http://help.infragistics.com/NetAdvantage/ASPNET/2010.3?page=WebGrid_Object_CSOM.html
Thanks for all your valuable input.
Yes, I do a full PostBack from the modal. I tried before the setActiveRow method before, but the problem is that when I do a grid refresh my grid is set only with the first 20 rows for example (Virtual scrolling) so in this case if I wanted to ge back to Row 25 for example it would not exist.
After reading a bit I found the workaround to my problem. Here it is so it might be useful for someone.
In my parent window:
var obj = new Object(); obj.data1 = gridLCN; 'grid was initialized to a variable onload obj.data2 = 'some data 2'; showModalDialog('child1.aspx', obj, '');
then on child:
<body onload="ReadPassedData()"> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return changeparent()"/> </div> </form></body>
I wasn't sure I could pass an object in the arguments to the child but it actually works!, so I guess I will do all the changes to the grid from javascript in my child window, a bit long but at least it does the job.
Forgot to include the routine in the child:
var grid=''; function ReadPassedData() { var obj = window.dialogArguments; grid = obj.data1; }
Regards,
HI Federico,
Thanks for sharing your solution with the community!