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

CommandItem Postback

1 Answer 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 02 Nov 2008, 01:10 AM
Not sure if this is possible but thought it would not hurt to ask.  I am creating a grid dynamically on my pages that is designed to display open employment positions.  I've followed the example in the help for creating a command item which will be used to allow applicants to submit their resume by opening a radWindow that has all the pertinent fields and upload capability.

What I don't want is the postback when the command button is clicked, since I intend (haven't tried yet so not sure I can) to set it as the opener element on my radWindowManager window and a server trip really isn't needed since I am doing it all client side.

So, is it possible to disable postbacks on this item?  I tried doing it at the button level when I add it and in the different MasterTableViews etc, but nothing obvious jumped out at me.

Also, if this is a silly approach let me know so I can find a different way to implement this.

Sam

1 Answer, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 02 Nov 2008, 02:17 AM
Seems this is a moot point, once I added the functionality so the new command item template button was set as the opener element for the radWindow it stopped the postback.  Here is my code for anyone that one day tries something similar:
(note: If you see any room for improvement I would love to hear it.)

This is the class to add the command item:
Imports Microsoft.VisualBasic 
Imports Telerik.Web.UI 
Imports System.Web.UI 
 
Public Class EmpItemTemplate 
    Implements ITemplate 
 
    Protected addResume As Button 
 
    Public Sub New() 
        MyBase.New() 
    End Sub 
 
    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn 
        addResume = New Button 
        addResume.ID = "addResume" 
        addResume.Text = "Submit Your Resume" 
 
        container.Controls.Add(addResume) 
    End Sub 
 
End Class 

And this is the page code:
    Private Sub GenerateGrid() 
        Dim rgNew As New RadGrid 
        Dim colNew As GridBoundColumn 
 
        'Basig Grid Settings 
        rgNew.ID = "rgEmpTable" 
        rgNew.AutoGenerateColumns = False 
        rgNew.Skin = "Vista" 
        rgNew.DataSourceID = "sqlPositions" 
        rgNew.ClientSettings.Selecting.AllowRowSelect = True 
        rgNew.AllowMultiRowSelection = True 
 
        'Add Command Item Submit Resume Button 
        rgNew.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top 
        rgNew.MasterTableView.CommandItemTemplate = New EmpItemTemplate 
 
        'Setup custom event handlers 
        AddHandler rgNew.ItemDataBound, AddressOf EmpGrid_ItemDataBound 
        AddHandler rgNew.ItemCreated, AddressOf EmpGrid_ItemCreated 
 
        'Add Columns 
        Dim colSel = New GridClientSelectColumn 
        colSel.UniqueName = "SelCol" 
        rgNew.MasterTableView.Columns.Add(colSel) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_id" 
        colNew.HeaderText = "employment_id" 
        colNew.Visible = False 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_date" 
        colNew.HeaderText = "Post Date" 
        colNew.DataFormatString = "{0:MM/dd/yyyy}" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_title" 
        colNew.HeaderText = "Job Title" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_type" 
        colNew.HeaderText = "Position Type" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_city" 
        colNew.HeaderText = "City" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_state" 
        colNew.HeaderText = "State" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "employment_positions" 
        colNew.HeaderText = "# Positions" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        colNew = New GridBoundColumn 
        colNew.DataField = "recruiter_name" 
        colNew.HeaderText = "Recruiter" 
        rgNew.MasterTableView.Columns.Add(colNew) 
 
        'Add grid to page 
        SubmitDiv.Controls.Add(rgNew) 
    End Sub 
 
    Protected Sub EmpGrid_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If TypeOf e.Item Is GridHeaderItem Then 
            Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem) 
            Dim chkbx As CheckBox = DirectCast(header("SelCol").Controls(0), CheckBox) 
            chkbx.Visible = False 
        End If 
    End Sub 
 
    Protected Sub EmpGrid_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If TypeOf e.Item Is GridCommandItem Then 
            Dim rgItem As GridCommandItem = DirectCast(e.Item, GridCommandItem) 
            Dim itemResume As Button = DirectCast(rgItem.FindControl("addResume"), Button) 
            SubmitResume.OpenerElementID = itemResume.ClientID 
        End If 
    End Sub 

Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Share this question
or