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

Hiding certain rows in a DetailTable on a condition

3 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carina
Top achievements
Rank 1
Carina asked on 14 Feb 2013, 06:46 PM
Hi,

I have a Radgrid on a main page, that when a record is double clicked, a radwindow opens up to update a record. There is a radgrid inside the Radwindow that is opened. Inside the radgrid that is inside the radwindow, I can set a record to be inactive and only be visible to certain users.

The Radgrid in the main page has one DetailTable. This detail table displays the information from the radgrid inside the radwindow. I want those records that I set to inactive to NOT be visible in the Radgrid in the mainpage. Is there a way to do this?

URGENT!

I am working in vb.net

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Feb 2013, 09:43 AM
Hi,

Please take a look into the following code snippet I tried to display the information from the radgrid inside the radwindow in Detail table.

MainPage.aspx

Javascript:
<script type="text/javascript">
    var data;
    function RowDblClick(sender, eventArgs) {      
        data = eventArgs.getDataKeyValue("CustomerID");
        window.radopen("../../RadWindoweditform.aspx?CustomerID=" + eventArgs.getDataKeyValue("CustomerID"), "UserListDialog");
    }
    function OnClientClose(oWnd, args) {
        var windowvalue = args.get_argument();
        var parentrowvalue = data;
        var newKey = windowvalue + "," + parentrowvalue;
        var grid = $find("<%=RadGrid1.ClientID %>");
        var masterTable = grid.get_masterTableView();
        masterTable.fireCommand("Open", newKey);
    }
    
</script>

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "Open")
    {
        string Datakeys = e.CommandArgument.ToString();
        string[] Ids = Regex.Split(Datakeys, ",");
        string childID = Ids[0];
        string ParentID = Ids[1];
        foreach(GridDataItem item in RadGrid1.MasterTableView.Items)
        {                   
            string parentrowdatakey = item.GetDataKeyValue("CustomerID").ToString();
            if (parentrowdatakey == ParentID)
            {
                item.Expanded = true;
                foreach (GridTableView detailtable in item.ChildItem.NestedTableViews)
                {
                    foreach (GridDataItem childItem in detailtable.Items)
                    {
                        string childrowdatakey = childItem.GetDataKeyValue("OrderID").ToString();
                        if (childrowdatakey == childID)
                        {
                            childItem.Visible = false;
                        }
                    }
                }
            }
        }
        
    }
}

RadWindoweditform.aspx

Javascript:
<script type="text/javascript">
 
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }
    function SelectItems(dataKey) {
        var oWnd = GetRadWindow();
        oWnd.close(dataKey);       
    }
</script>

C#:
protected void LinkButton1_Click(object sender, EventArgs e)
{
    LinkButton LinkButton1 = (LinkButton)sender;
    GridDataItem ditem = (GridDataItem)LinkButton1.NamingContainer;
    string datakey = ditem.GetDataKeyValue("OrderID").ToString();
 
    string openWindowScript = "<script language='javascript'>function f(){SelectItems('"+datakey+"'); Sys.Application.remove_load(f) ;}; Sys.Application.add_load(f)  ;</script>";
    Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", openWindowScript);      
    ditem.Visible = false
}

Thanks,
Shinu.
0
Carina
Top achievements
Rank 1
answered on 15 Feb 2013, 10:42 PM
Hi,

That is not what I wanted sorry if I did not explain myself clearly. I am working in vb.net NOT c#. The main page has a radgrid, that has a detail table in each record. That detail table information comes from one of the radgrids in a radwindow. So I want to save the form in the radwindow, then go back to the main page and click on one of the records, expand so the Detail Table shows, but I only want the active records inside the detail table to show. is that possible? I also have the main page with the radwindow and detial table working. I just need to be able to only show active records inside the Detail table. Inside the radwindow, those records are already being read as inactive and do not display, but in the detail table in the main page, all the records in that table show up regardless if they are active or not.

I have attached a preview, and inside the radwindow, you can see that one record is inactive (the light grey one), and so I do not want that record to show up in the main grid as it is doing so, so far. Any help?
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2013, 07:35 AM
Hi,

Unfortunately the given information is not enough to replicate the problem you are facing. Please provide the complete code for me to understand how are you making the RadWindow RadGrid's certain row inactive and also what is the criteria used to bind the detail grid based on the grid inside window.

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