<
telerik:RadGrid
ID
=
"RadGridEmployeeCost"
runat
=
"server"
AllowSorting
=
"True"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"true"
CellSpacing
=
"0"
GridLines
=
"None"
HeaderStyle-Font-Bold
=
"true"
Skin
=
"Web20"
OnNeedDataSource
=
"RadGridEmployeeCost_NeedDataSource"
ShowGroupPanel
=
"true"
OnColumnCreated
=
"RadGridEmployeeCost_ColumnCreated"
>
<
ClientSettings
AllowDragToGroup
=
"True"
/>
</
telerik:RadGrid
>
protected void RadGridEmployeeCost_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
ObjCon.Open();
SqlCommand ObjCmd = new SqlCommand("SELECT name,address,TelPhone,EmailId,Qualification FROM WorkSummary", ObjCon);
ObjCmd.ExecuteNonQuery();
SqlDataAdapter ObjDa = new SqlDataAdapter(ObjCmd);
DataSet ds = new DataSet();
ObjDa.Fill(ds);
RadGridEmployeeCost.DataSource = ds;
}
}
protected void RadGridEmployeeCost_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if ((e.Column is GridBoundColumn && e.Column.UniqueName == "TelPhone" || e.Column.UniqueName == "EmailId" || e.Column.UniqueName == "Qualification"))
{
GridBoundColumn column = e.Column as GridBoundColumn;
column.AllowFiltering = false;
}
}
In each row of a grid with EditType = "Row", I'm trying to show/hide the column editor controls based on data in that row. When some rows are in edit mode (after being clicked on), they will display a text box, checkbox, etc. approporiate for that particular row. Other rows will hide that option in the same column.
For the entire column, edit controls can be shown/hidden based on the column's ReadOnly field. Can this be turned on/off for individual rows?
Would prefer to handle this server-side. Trying to avoid managing dynamically added controls based on data conditions and instead simply turn on/off editing in specific cells of each row.
In the example below, when a row is in edit mode, I want the edit text box in the MilkType column to only display if the Product for that row is Milk. Otherwise the cell should be read-only when the row is in edit mode.
Thanks!
-Matt
(posting code separately - having problems submitting new thread with code blocks)
Hello all,
I am having trouble with the calculated column. everything works well until the calculated column is added then I get error message "Identifier expected".
Have gone through the documentations and examples but cannot figure out what's wrong and why it's not working.
Here is the code below. Any insight would be appreciated. Thanks!
<
telerik:RadGrid
ID
=
"ReportGrid"
runat
=
"server"
DataSourceID
=
"SearchResultDataSource"
>
<
MasterTableView
DataSourceID
=
"SearchResultDataSource"
AllowPaging
=
"false"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"name_last_first"
HeaderText
=
"Name"
SortExpression
=
"name_last_first"
UniqueName
=
"name_last_first"
Aggregate
=
"CountDistinct"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"07"
HeaderText
=
"July"
SortExpression
=
"07"
UniqueName
=
"07"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"08"
HeaderText
=
"Aug"
SortExpression
=
"08"
UniqueName
=
"08"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"09"
HeaderText
=
"Sept"
SortExpression
=
"09"
UniqueName
=
"09"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"10"
HeaderText
=
"Oct"
SortExpression
=
"10"
UniqueName
=
"10"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"11"
HeaderText
=
"Nov"
SortExpression
=
"11"
UniqueName
=
"11"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"12"
HeaderText
=
"Dec"
SortExpression
=
"12"
UniqueName
=
"12"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"01"
HeaderText
=
"Jan"
SortExpression
=
"01"
UniqueName
=
"01"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"02"
HeaderText
=
"Feb"
SortExpression
=
"02"
UniqueName
=
"02"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"03"
HeaderText
=
"Mar"
SortExpression
=
"03"
UniqueName
=
"03"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"04"
HeaderText
=
"April"
SortExpression
=
"04"
UniqueName
=
"04"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"05"
HeaderText
=
"May"
SortExpression
=
"05"
UniqueName
=
"05"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridNumericColumn
DataField
=
"06"
HeaderText
=
"June"
SortExpression
=
"06"
UniqueName
=
"06"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
/>
<
telerik:GridCalculatedColumn
HeaderText
=
"Opened"
UniqueName
=
"Opened"
Aggregate
=
"Sum"
FooterAggregateFormatString="<b>{0:d}</
b
>"
DataFormatString="{0:d}"
DataType="System.Int32"
DataFields="01,02,03,04,05,06,07,08,09,10,11,12"
Expression="{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}"
/>
</
Columns
>
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"unit_type"
HeaderText
=
" "
SortOrder
=
"Ascending"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"unit_type"
HeaderText
=
" "
HeaderValueSeparator
=
" "
SortOrder
=
"Ascending"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"unit_name"
HeaderText
=
" "
SortOrder
=
"Ascending"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"unit_name"
HeaderText
=
" "
HeaderValueSeparator
=
" "
SortOrder
=
"Ascending"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SearchResultDataSource"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="rpt_getOpenAndAssignedByMonthForUnit" EnableCaching="False" SelectCommandType="StoredProcedure">
<
SelectParameters
>
<
asp:ControlParameter
Name
=
"int_fy"
Type
=
"Int32"
PropertyName
=
"Text"
ControlID
=
"YearTxt"
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
DataSourceID
=
"SqlDataSource1"
runat
=
"server"
OnUpdateCommand
=
"RadGrid1_UpdateCommand"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"False"
AllowPaging
=
"False"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
OnItemUpdated
=
"RadGrid1_ItemUpdated"
OnItemDeleted
=
"RadGrid1_ItemDeleted"
OnItemInserted
=
"RadGrid1_ItemInserted"
OnInsertCommand
=
"RadGrid1_InsertCommand"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
OnItemCreated
=
"RadGrid1_ItemCreated"
Width
=
"950"
>
<
MasterTableView
DataSourceID
=
"SqlDataSource1"
DataKeyNames
=
"ID"
AllowMultiColumnSorting
=
"True"
Width
=
"100%"
CommandItemDisplay
=
"Top"
Name
=
"Questions"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"ID"
DataSourceID
=
"SqlDataSource2"
Width
=
"100%"
runat
=
"server"
CommandItemDisplay
=
"Top"
Name
=
"Answers"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"QuestionID"
MasterKeyField
=
"ID"
></
telerik:GridRelationFields
>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn1"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"MyImageButton"
></
ItemStyle
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"QuestionID"
HeaderText
=
"Question"
HeaderButtonType
=
"TextButton"
DataField
=
"QuestionID"
UniqueName
=
"QuestionID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"AnswerText"
HeaderText
=
"Answer Text"
HeaderButtonType
=
"TextButton"
DataField
=
"AnswerText"
UniqueName
=
"AnswerText"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"PanelAmount"
HeaderText
=
"Panel Amount"
HeaderButtonType
=
"TextButton"
DataField
=
"PanelAmount"
UniqueName
=
"PanelAmount"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
SortExpression
=
"IsEnd"
HeaderText
=
"Is End"
HeaderButtonType
=
"TextButton"
DataField
=
"IsEnd"
UniqueName
=
"IsEnd"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"LabelIsEnd"
runat
=
"server"
><%# DataBinder.Eval(Container.DataItem, "IsEnd")%></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBoxIsEnd"
runat
=
"server"
Checked='<%#Eval("IsEnd") %>' />
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"JumpToQuestion"
HeaderText
=
"Jump To Question"
HeaderButtonType
=
"TextButton"
DataField
=
"JumpToQuestion"
UniqueName
=
"JumpToQuestion"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
SortExpression
=
"StartSurvey"
HeaderText
=
"Start Survey"
HeaderButtonType
=
"TextButton"
DataField
=
"StartSurvey"
UniqueName
=
"StartSurvey"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"LabelStartSurvey"
runat
=
"server"
><%# DataBinder.Eval(Container.DataItem, "StartSurvey")%></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBoxStartSurvey"
runat
=
"server"
Checked='<%#Eval("StartSurvey") %>' />
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumnAnswer"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn1"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"MyImageButton"
></
ItemStyle
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"ID"
HeaderText
=
"ID"
HeaderButtonType
=
"TextButton"
DataField
=
"ID"
UniqueName
=
"ID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"QuestionText"
HeaderText
=
"Question Text"
HeaderButtonType
=
"TextButton"
DataField
=
"QuestionText"
UniqueName
=
"QuestionText"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
SortExpression
=
"QuestionType"
HeaderText
=
"Question Type"
HeaderButtonType
=
"TextButton"
DataField
=
"QuestionType"
UniqueName
=
"QuestionType"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"LabelQuestionType"
runat
=
"server"
><%# DataBinder.Eval(Container.DataItem, "QuestionType")%></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"DropDownListQUestionType"
runat
=
"server"
></
asp:DropDownList
>
<%--<
asp:DropDownList
ID
=
"DropDownListQUestionType"
runat
=
"server"
SelectedValue='<%#Eval("QuestionType") %>'></
asp:DropDownList
>--%>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"QuestionPosition"
HeaderText
=
"Question Position"
HeaderButtonType
=
"TextButton"
DataField
=
"QuestionPosition"
UniqueName
=
"QuestionPosition"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumnQuestion"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:Local_TypingTool_NewConnectionString %>"
UpdateCommand="UPDATE [Screener_Questions] SET [QuestionText] = @QuestionText, [QuestionType] = @QuestionType, [QuestionPosition] = @QuestionPosition WHERE [ID] = @ID"
SelectCommand="SELECT [ID], [QuestionText], [QuestionType], [QuestionPosition] FROM Screener_Questions WHERE [Survey_ID] = @Survey_ID"
InsertCommand="INSERT INTO [Screener_Questions] ([Survey_ID], [QuestionText], [QuestionType], [QuestionPosition]) VALUES (@Survey_ID, @QuestionText, @QuestionType, @QuestionPosition)"
DeleteCommand="DELETE FROM [Screener_Questions] WHERE [ID] = @ID">
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Survey_ID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"QuestionText"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"QuestionType"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"QuestionPosition"
Type
=
"Int32"
/>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"QuestionText"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"QuestionType"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"QuestionPosition"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"Survey_ID"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
DropDownList list = editedItem.FindControl("DropDownListQUestionType") as DropDownList;
Session["updatedValueQUestionType"] = list.SelectedValue;
}