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

Radgrid, not able to set page and item selected (chrome)

2 Answers 52 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Oscar Emiliano
Top achievements
Rank 1
Oscar Emiliano asked on 28 Jul 2015, 03:24 PM

Good morning Community,

 I'm having an issue under Chrome browser that is not allowing me to set the page index and a selected item. The scenario is that I have a main page showing a list of items. I use RadWindow as popup to add & edit actions. At code behind I use try and catch. If no exception is catched I call a javascript function to close RadWindow and pass "ok" as parameter, in case of an exception inside catch I call the same function but with "error" as parameter.

This function looks as follow, depending the parameter I am calling two different javascript functions from parent page:

 function CloseWindow(refreshParent) {

            GetRadWindow().close(); 
            if (refresh​Parent == "yes") {
                    CallFunctionOnParentPage("RefreshSuccess");
            }    
            else {
                CallFunctionOnParentPage("RefreshError");    
            }
        }​

These functions from parent are used to refresh grids and show message of success or error at the top of the page. A postback is executed, I set the EVENTTARGET (1st value) and EVENTARGUMENT (2nd value):

function RefreshSuccess() {
            __doPostBack("<%= uppMain.ClientID %>", "ok");
        } 

function RefreshError() {
            __doPostBack("<%= uppMain.ClientID %>", "error");
        }

So, when the postback is executed on parent's Page_Load method (at code behind) I'm checking the value of target & argument and then I can set the color of the message (blue if success, salmon when error)

string eventTarget = Request.Params.Get("__EVENTTARGET");
switch (eventTarget)
{
                    case "MainCPH_uppMain": 

                    string resultMessage = Request.Params.Get("__EVENTARGUMENT");

                    if (resultMessage == "ok")
                    {
                            lblMessage.Attributes.Add("style", "display:block");
                            lblMessage.BackColor = System.Drawing.Color.LightSkyBlue;
                            lblMessage.Text = "The information has been successfully saved.";

                    }

                    else

                    {

                            lblMessage.Attributes.Add("style", "display:block");
                            lblMessage.BackColor = System.Drawing.Color.Salmon;
                            lblMessage.Text = "A problem has ocurred when saving the information.";​

                    }

}

When adding a new item to the grid (alphabetic order), I require to make the new element appear as selected, including if necessary a change of page. For this, when the save was successful I'm searching for the newest item's ID, page by page and set its selected property to true:

NOTE: I am using multi-tier structure, so I have a Model layer where I have a definition of the model Item, I use a list of those models as datasource of the grid and that is why I cast the items to that model.

                            int i = 0;
                            for(i=0; i < gridItems.PageCount; i++)
                            {
                                gridItems.CurrentPageIndex = i;
                                gridItems.MasterTableView.Rebind();
                                foreach (GridDataItem item in gridItems.Items)
                                {
                                    Model.​Item ​myItem= (Model.​Item)item.DataItem;
                                    if (​myItem.CompanyID == ​newestID)
                                    {
                                        item.Selected = true;                                                                         
                                        break; // break, once it is found there is no need to keep searching
                                    }
                                }                               
                            } 

And well, here is the issue, everything is working just fine under Firefox and Internet Explorer, but for some reason is not working under chrome, the page of the grid is not changing and the new item does not appear as selected. So, the .CurrentPageIndex and the .Selected seems not to be working. Any ideas?

 I tried to simplify my example, the real page is using different tabs (that's why I need the EVENTTARGET, as sometimes I only need to refresh one tab but in some cases I need to refresh multiple tabs). The page is also calling different RadWindows. That is why I would like to keep the solution of the issue at the same level that I have the logic, at Page_Load method under Parent's codebehind.

Thanks in advance, any hint will be highly appreciated. Let me know if more details are required. 

Regards, 

Oscar

2 Answers, 1 is accepted

Sort by
0
Oscar Emiliano
Top achievements
Rank 1
answered on 29 Jul 2015, 01:48 PM

Hi again, any admin that could give some help?

 Thanks in advance, regards

0
Konstantin Dikov
Telerik team
answered on 31 Jul 2015, 11:19 AM
Hi Oscar,

It seems that you have a rather complex scenario and without a sample project it will be really difficult to determine what could be causing the issue in Chrome. Can you please debug your page and see if the logic for setting the selected item and the page index is executed when you run the page in Chrome?

As for any particular suggestion, can you please open a regular support ticket and attach a sample, runnable project that replicates the problem, so we can test it locally. 


Best Regards,
Konstantin Dikov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Ajax
Asked by
Oscar Emiliano
Top achievements
Rank 1
Answers by
Oscar Emiliano
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or