Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
716 views

Hi,

In my web application, I am trying to integrate RadGrid from code behind and depending on the GridBoundColumn DataField “Status” (having value 1 and 0), I would like to show/hide “Deactivate”/”Activate” image command button written under ItemTemplate, After lot of Googling, I couldn’t find similar solution. If there is any way out to achieve this, please suggest.

My code is as followes,

<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="True"  AllowPaging="True" AllowSorting="True" AllowAutomaticDeletes="True" OnItemCommand="RadGrid1_ItemCommand"> 

    <MasterTableView EditMode="PopUp" PageSize="20"                                AutoGenerateColumns="False"  DataKeyNames="Consequence_Id" ClientDataKeyNames="Consequence_Id">

     <PagerStyle Mode="NextPrevAndNumeric" />

        <Columns>

        <telerik:GridBoundColumn DataField="Module_Content_Text"

            HeaderText="Consequence_Name" SortExpression="Module_Content_Text"

            UniqueName="Module_Content_Text">

        </telerik:GridBoundColumn>

 

        <telerik:GridBoundColumn DataField="Status" Visible="false"

            UniqueName="Status">

        </telerik:GridBoundColumn>

<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">

<HeaderTemplate>

               <table width="100%">

                  <tr>

                    <td>

                       Options</td>

                     </tr>

                     </table>

                </HeaderTemplate>

<ItemTemplate>

    <table width="100%">

        <tr>

            <td>

               <asp:ImageButton ID="ImgBtnDeactivate" ToolTip="Deactivate Record" runat="server" CausesValidation="False" CommandName="Deselect" OnClientClick="return confirm('Are you sure you want to Deactivate this record?');" ImageUrl="~/Images/icon/cross.gif" />

            </td>

            <td>

               <asp:ImageButton ID="ImgBtnActivate" ToolTip="Activate Record" runat="server" CausesValidation="False" CommandName="Select" OnClientClick="return confirm('Are you sure you want to Activate this record?');" ImageUrl="~/Images/icon/right.gif" />

                </td>

                <td>

                    <asp:ImageButton ID="ImgBtnDelete" ToolTip="Delete Record" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');"  ImageUrl="~/Images/icon/delete.gif" />

                </td>

                <td>

                   <asp:ImageButton ID="ImgBtnEdit" ToolTip="Edit Record" runat="server" CausesValidation="False" CommandName="Edit" OnClientClick="return confirm('Are you sure you want to Edit this record?');"  ImageUrl="~/Images/icon/edit.gif" />

                </td>

            </tr>

        </table>

    </ItemTemplate>

            </telerik:GridTemplateColumn>

</Columns>

           </MasterTableView>

 

------------------------------------------------

 private void displayConsequenceGrid()
    {
        MiddleWare.BL.Consequence objC = new MiddleWare.BL.Consequence();
        DataTable dt = new DataTable();
        objC._Company_Id = System.Convert.ToInt32(Session[CSession.__Session_Company_Id]);
        objC._Language_Id = System.Convert.ToInt32(Session[CSession.__Session_Lanuage_Id]);
        dt = objC.GetDataAllConsequence();
        RadGrid1.DataSource = dt;
        RadGrid1.DataBind();

     }

 protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        int retResult = -100;
        MiddleWare.BL.Consequence oConsq = new MiddleWare.BL.Consequence();
        oConsq._Updated_By = Convert.ToInt32(Session[CSession.__Session_User_Id]);
        oConsq._Module_Id = oConsq._Module_Id;

  if (e.CommandName == RadGrid.EditCommandName)
        {
            int Consequence_Id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Consequence_Id"].ToString());
        }

 else if (e.CommandName == RadGrid.DeleteCommandName)
        {
            oConsq._Consequence_Id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Consequence_Id"].ToString());
            retResult = oConsq.DeleteConsequence();
            if (retResult == 2)
            {
                displayConsequenceGrid();
            }
           
        }

 else if (e.CommandName == RadGrid.SelectCommandName)
        {
            oConsq._Consequence_Id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Consequence_Id"].ToString());

            retResult = oConsq.ActivateConsequence();
            if (retResult == 1)
            {
                displayConsequenceGrid();
            }
        }


I am attaching the required result page as attached picture. Please help me out.

 

Debashis Pyne
Top achievements
Rank 1
 answered on 30 Jun 2010
2 answers
431 views
Hi all,
 
          I am using a radcombobox with allowcustomtext = true intended for adding new values not present in the list. When i click on the combobox it gets opened and by default selection points to the first item. Still I can type a text, but when i  press the "enter key instead of the value i typed it commits the one on which the selection was there. I browsed through the documents and came to know this is the default action on pressing the Enter. But is there any way to avoid this and retain the values typed. Please help.

Regards,
Saravanan K

saravanan k
Top achievements
Rank 1
 answered on 30 Jun 2010
1 answer
105 views
Hi again

Wondering if you knew if the latest version of the Telerik controls has an issue with displaying the icons in the grid toolbar.  I know it was working in previous versions.  I may have changed something that would have caused it to break, but I'm not sure.  As an example, here is what I have in my App_Themes\vista.css file.  We use all the different skins, but just chose the Vista as an example.

.reToolbar.Vista

 

.tbiEntity {

 

 

background-image: url(/images/rgb.png);

 

}


Additionally, I am aware that there is a hotfix, but when I tried to use it (I moved the contents of the last version to a backup folder and copied the contents of the zip file to the Telerik directory), I get the following error:
Package Load Failure
Package 'Telerik.Web.UI .... has failed to load properly (GUID={057D8865-D4BB-46E8-E24FD08F489}}.  Please contact package vendor for...

Thanks in advance.
Rumen
Telerik team
 answered on 30 Jun 2010
1 answer
84 views
After trying for hours to accomplish something that in theory should be a simple task, i've decided to turn to the forums for help!

I have a tree view (with checkboxes) with ONE parent node, and multiple child nodes.

I also have an asp:OptionButtonList, with three options: Full, Partial, and None.

If a user clicks "Full", the Parent node and child nodes should be checked.

If a user clicks "Partial", only the Parent node should be checked...no child nodes.

And, obviously, if a user clicks "None", no nodes should be checked.

I can get the Full and None options to work...but not the partial.

Can anyone help?

So far i'm doing this:

switch (rbl.SelectedValue)  
            {  
                case "Full":  
                    radTreeView.CheckAllNodes();  
                    return;  
                case "None":  
                    isChecked = false;  
                    break;  
                case "Partial":  
                    isChecked = false;  
                    break;  
                default:  
                    break;  
            }  
 
            foreach (RadTreeNode node in radTreeView.Nodes)  
            {           
                node.Checked = isChecked;                  
            } 

obviously this isn't going to accomplish what I want for the "Partial" option, but i've tried what seems like a billion different things, and I can't seem to just check the Parent Node...

Thanks in advance!
V
Nikolay Tsenkov
Telerik team
 answered on 30 Jun 2010
1 answer
62 views
Hi, I have a problem with a WebUserControl edit form of a rad grid, the problem is that the popup appears inside the radgrid and the overflow is hidden so the popup doesnt show. You can see the attached image for more information. Do you know why is this?
Rosen
Telerik team
 answered on 30 Jun 2010
1 answer
67 views
HI,

In treeview bind only root nodes with ServerSideCallBack when i click on plus image  its child node is loaded without post back
in this process i assign  imageurl property 
Node.ImageUrl = Row("ImageUrl").ToString()

Row("ImageUrl") contain value "Q1".

when I postback page and then get imageurl property, i get website URL with "Q1" like
"http://mysite/View/Q1"

i need only "Q1"

how can i get this value.

Thanks in advance

regards,
sadiq modan
Nikolay Tsenkov
Telerik team
 answered on 30 Jun 2010
1 answer
216 views
I have radgrid1 for the inline editing and I have Edit, Add New Record, Delete links but also I added extra gridboundbutton called " search" and I wan to put a pop up panel for that in ItemCommand.. but my panel is not showing up.. I have searched that it says if I would have want to do my edit pop up panel I could have add EditMode = popup on the aspx page but I am not sure how to do that for the Search link, because I dont want to add pop up to Edit, Add new record , Delete functionalities.. just for Search .

 <radG:GridButtonColumn  ButtonType="LinkButton"
                          CommandName="Search" UniqueName="Search" >
                          <HeaderStyle />
                          <ItemStyle HorizontalAlign="Center" />
                      </radG:GridButtonColumn>
Veli
Telerik team
 answered on 30 Jun 2010
1 answer
91 views
From the help, these two functions are same.
Rumen
Telerik team
 answered on 30 Jun 2010
6 answers
223 views
Hi,

Can you please point me to an example that uses linq data as a source for the grid in the scenario something like below:

 

 

 

 

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 

{

    RadGrid1.DataSource =

 

this.GridSource2;

 

}

 

 

 

private object GridSource2

 

{

 

 

get

 

 

 

 

 

{

 

 

Object obj = this.ViewState["_gds"];

 

 

 

if (obj != null)

 

{

 

 

return obj;

 

}

 

 

else

 

 

 

 

 

{

 

 

string s;

 

 

 

 

 

 

 

 

 

 

object ss = from i in EntityConnection.INVENTORY select new { i.INV_DEVICENAME, i.INV_DEVICETYPE };

 

 

 

this.ViewState["_gds"] = ss;

 

 

 

return ss;

 

}

}

}

Al
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 30 Jun 2010
2 answers
174 views
I have a simple grid where I allow sorting. the datasource is filled with the needdatasource event. This funtion puts an IEnumerable<Canidate> into the datasource.
When I click the header of a column for the first time, everything works wel. When I click the header of the column next to the previous column, the column to right of the column I clicked is then sorted. also the sortmode is not changing when click multiple times on the same header. I have also tested this with auto generate columns, but this produces the same error.

Does anyone has an idea what is going on?

here is my code behind:

  protected void CandidateListGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            RadComboBox lastNameInput = (RadComboBox)FilterData.FindControl("LastNameInput"); 
            RadComboBox firstNameInput = (RadComboBox)FilterData.FindControl("FirstNameInput"); 
            RadDatePicker dateLastContractFromInput = (RadDatePicker)FilterData.FindControl("DateLastContractFromInput"); 
            RadDatePicker dateLastContractUntilInput = (RadDatePicker)FilterData.FindControl("DateLastContractUntilInput"); 
            RadComboBox StatusComboBox = (RadComboBox)FilterData.FindControl("StatusComboBox"); 
 
            var statusItems = from itm in StatusComboBox.Items 
                              where ((CheckBox)itm.FindControl("CheckBox")).Checked 
                              select itm.Value; 
 
            CandidateListGrid.DataSource = this.presenter.ListCandidates( 
                ((lastNameInput != null) ? lastNameInput.Text : "") 
                , ((firstNameInput != null) ? firstNameInput.Text : "") 
                , statusItems 
                , ((dateLastContractFromInput != null) ? dateLastContractFromInput.SelectedDate : DateTime.MinValue) 
                , ((dateLastContractUntilInput != null) ? dateLastContractUntilInput.SelectedDate : DateTime.MinValue) 
                ); 
             
        } 

here is my ascx

 <telerik:RadGrid ID="CandidateListGrid" runat="server" AllowPaging="True" AllowSorting="true" GridLines="None" 
        AutoGenerateColumns="False" PageSize="10" 
        AllowMultiRowSelection="True" EnableEmbeddedSkins="False" Skin="USGFOEXTelerik" 
        OnNeedDataSource="CandidateListGrid_NeedDataSource" > 
        <MasterTableView ClientDataKeyNames="ID"> 
            <Columns> 
                <telerik:GridBoundColumn DataField="LastName" HeaderText="Naam" SortExpression="LastName" 
                    UniqueName="LastName"> 
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="FirstName" HeaderText="Voornaam" SortExpression="FirstName" 
                    UniqueName="FirstName"> 
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ContractState" HeaderText="Status" SortExpression="ContractState" 
                    UniqueName="ContractState"> 
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="LastContractDate" DataType="System.DateTime" 
                    HeaderText="Laatste contract" SortExpression="LastContractDate" UniqueName="LastContractDate"> 
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 
here is my Candidate class:

  public class Candidate 
    { 
        public int Id { get; set; } 
        public string FirstName { get; set; } 
        public string LastName { get; set; } 
        public DateTime LastContractDate { get; set; } 
        public string ContractState { get; set; } 
} 

Michaël Kiekens
Top achievements
Rank 1
 answered on 30 Jun 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?