create button to insert in the same row value

3 posts, 0 answers
  1. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 03 May 2013 Link to this post

    Hello ,

    i need to create a column in the grid , contain button this button " confirm "  when i press on it i want to add value " Confirmed "
    in specific cell

     
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 05 May 2013 Link to this post

    Hello,

    Client side

    <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" ClientDataKeyNames="ID"
    >
                    <Columns>
                        <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn Text="set confirm text in name column and template column"
                            UniqueName="buttoncolumn" ButtonType="PushButton">
                        </telerik:GridButtonColumn>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server"></asp:Label>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridEditCommandColumn>
                        </telerik:GridEditCommandColumn>
                    </Columns>
                </MasterTableView>
    function setConfirmtext(objid,ID) {
                     
                    // set in template column
                    $('#' + objid + 'Label1').html('jayesh');
     
                    // set in bound column
                    var grid = $find("<%= RadGrid1.ClientID %>");
                    if (grid) {
                        var MasterTable = grid.get_masterTableView();
                        var Rows = MasterTable.get_dataItems();
                        for (var i = 0; i < Rows.length; i++) {
                            var row = Rows[i];
                            var ClientDataKey_ID = row.getDataKeyValue("ID");
                            if (ClientDataKey_ID == ID) {
                                row.get_cell("Name").innerHTML = "jayesh";
                            }
                        }
                    
     
                     
                }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            {
     
                if (e.Item is GridDataItem)
                {
                    GridDataItem item = e.Item as GridDataItem;
                    Button btn = item["buttoncolumn"].Controls[0] as Button;
                    btn.Attributes.Add("onclick", "setConfirmtext('" + btn.ClientID.Substring(0, btn.ClientID.LastIndexOf("_") + 1) + "','" + item.GetDataKeyValue("ID").ToString() + "'); return false;");
                }
     
    }



    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 05 May 2013 Link to this post

    Hello,

    Server side.

    <Columns>
                       <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                       </telerik:GridBoundColumn>
                       <telerik:GridButtonColumn Text="set confirm text in name column and template column"
                           UniqueName="buttoncolumn" ButtonType="PushButton" CommandName="mycommand">
                       </telerik:GridButtonColumn>
                       <telerik:GridTemplateColumn>
                           <ItemTemplate>
                               <asp:Label ID="Label1" runat="server"></asp:Label>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridEditCommandColumn>
                       </telerik:GridEditCommandColumn>
                   </Columns>
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
            {
                if (e.CommandName == "mycommand")
                {
                    GridDataItem item = e.Item as GridDataItem;
                    Label Label1 = item.FindControl("Label1") as Label;
                    Label1.Text = item["Name"].Text = "yourtext";
                }
            }


    Thanks,
    Jayesh Goyani
Back to Top