Hi all,
I'm doing grid that some row are able to edit but some are disable.
I added GridEditCommandColumn to the grid and check at RadGrid1_PreRender event to hide Edit command at some rows as below...
Private
Sub
RadGrid1_PreRender(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadGrid1.PreRender
For
rowindex = RadGrid1.Items.Count - 1
To
0
Step
-1
Dim
row
As
GridDataItem = RadGrid1.Items(rowindex)
If
row.Cells(9).Text =
"T"
Then
'Hides the Edit command for the row with Category = T
row.Cells(6).Controls(0).Visible =
False
End
If
Next
End
Sub
Now I wanna add the feature RowDoubleClick to Edit data as below...
<
ClientSettings
>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
/>
</
ClientSettings
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function RowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</
script
>
</
telerik:RadCodeBlock
>
But now every row can edit data. I want to disable RowDoubleClick at some rows those I made Edit Command to invisible.
Please advise how can I do this?
Thanks
8 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 13 Jan 2011, 06:46 AM
Hello,
You could check for the cell value in the client side event handler itself and make the row in editmode accordingly.
Client code:
Best of luck.
-Shinu.
You could check for the cell value in the client side event handler itself and make the row in editmode accordingly.
Client code:
function
OnRowDblClick(sender, args) {
if
(args.get_gridDataItem().get_cell(
"ColumnUniqueName"
).innerText ==
"T"
) {
// Check for the condition
sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
}
}
Best of luck.
-Shinu.
0
Naunton
Top achievements
Rank 1
answered on 13 Jan 2011, 08:35 AM
Hi Shinu,
Thanks for your reply ..
But not solved yet ...
As per your suggestion..
At first got error : get_gridDataItem() is null or not an object ..
After add RowCreating and RowCreated
got error : get_gridDataItem().get_cell(...).innerText is null or not an object
Then change get_cell() to get_dataItem() as below...
still got error : get_gridDataITem().get_dataITem().Category is null or not an object
Please Please ...
Thanks for your reply ..
But not solved yet ...
As per your suggestion..
At first got error : get_gridDataItem() is null or not an object ..
After add RowCreating and RowCreated
function
RowCreating(sender, eventArgs) { }
function
RowCreated(sender, eventArgs) { }
function
RowDblClick(sender, eventArgs) {
if
(eventArgs.get_gridDataItem().get_cell(
"Category"
).innerText !=
"T"
)
{
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
}
got error : get_gridDataItem().get_cell(...).innerText is null or not an object
Then change get_cell() to get_dataItem() as below...
function
RowDblClick(sender, eventArgs) {
if
(eventArgs.get_gridDataItem().get_dataItem()[
"Category"
] !=
"T"
)
{
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
}
still got error : get_gridDataITem().get_dataITem().Category is null or not an object
Please Please ...
0
Hi naunt,
Can you try modifying the code as below:
All the best,
Iana
the Telerik team
Can you try modifying the code as below:
function
OnRowDblClick(sender, args) {
var
row = sender.get_masterTableView().get_dataItems()[args.get_itemIndexHierarchical()];
if
(row.get_cell(
"ColumnUniqueName"
).innerText ==
"T"
) {
// Check for the condition
sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
}
}
All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Naunton
Top achievements
Rank 1
answered on 18 Jan 2011, 12:12 PM
Dear Iana,
Thanks for the reply. But still got the error 'get_cell(...).innerText' is null or not an object'. Is there any other way, Please?
Thanks and Best Regards
Thanks for the reply. But still got the error 'get_cell(...).innerText' is null or not an object'. Is there any other way, Please?
Thanks and Best Regards
0
Hello naunt,
Indeed, this is the right approach for getting cells values on the client. Another option is to traverse the DOM tree till you find the desired cell. However this is not suggested approach.
Therefore, can you share the full page code so I can try debugging it on my side and see why you are receiving the mentioned error.
Best wishes,
Iana
the Telerik team
Indeed, this is the right approach for getting cells values on the client. Another option is to traverse the DOM tree till you find the desired cell. However this is not suggested approach.
Therefore, can you share the full page code so I can try debugging it on my side and see why you are receiving the mentioned error.
Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Naunton
Top achievements
Rank 1
answered on 19 Jan 2011, 02:22 AM
Thanks Iana.
Here is the full code.
Thanks and best regards.
Here is the full code.
<%@ Page Title="Form1" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
CodeBehind="WebForm1.aspx.vb" Inherits="MyWebApp.WebForm1" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<
asp:Content
ID
=
"HeaderContent"
runat
=
"server"
ContentPlaceHolderID
=
"HeadContent"
>
</
asp:Content
>
<
asp:content
id
=
"Content3"
contentplaceholderid
=
"Header"
runat
=
"server"
>
Grid
</
asp:content
>
<
asp:Content
ID
=
"BodyContent"
runat
=
"server"
ContentPlaceHolderID
=
"MainContent"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function RowCreating(sender, eventArgs) { }
function RowCreated(sender, eventArgs) { }
// function RowDblClick(sender, eventArgs) {
// //if (eventArgs.get_gridDataItem().get_dataItem()["Category"] != "T")
// if (eventArgs.get_gridDataItem().get_cell("Category").innerText != "T")
// {
// sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
// }
// }
function RowDblClick(sender, args) {
var row = sender.get_masterTableView().get_dataItems()[args.get_itemIndexHierarchical()];
if (row.get_cell("Category").innerText != "T") { // Check for the condition
sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
div
class
=
"title"
>
<
h2
>
</
h2
>
</
div
>
<
div
class
=
"body"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowMultiRowEdit
=
"True"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
PageSize
=
"20"
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Skin
=
"Windows7"
GridLines
=
"None"
>
<
MasterTableView
ShowHeadersWhenNoRecords
=
"True"
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"Srno"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"True"
>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
BackColor
=
"#F5F5DC"
/>
<
CommandItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ToolTip
=
"Update"
CommandName
=
"UpdateAll"
ID
=
"UpdateAll"
ImageUrl
=
"~/images/gnome_document_save_as.png"
/>
<
asp:ImageButton
runat
=
"server"
ToolTip
=
"Refresh/Search"
CommandName
=
"Refresh"
ID
=
"Refresh"
ImageUrl
=
"~/images/view_refresh.png"
/>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"POL"
FilterControlWidth
=
"50px"
HeaderText
=
"POL"
SortExpression
=
"POL"
UniqueName
=
"POL"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Vsl"
FilterControlWidth
=
"100px"
HeaderText
=
"Vsl"
SortExpression
=
"Vsl"
UniqueName
=
"Vsl"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"130px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Voy"
FilterControlWidth
=
"50px"
HeaderText
=
"Voy"
SortExpression
=
"Voy"
UniqueName
=
"Voy"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Srno"
DataType
=
"System.Int64"
HeaderText
=
"Srno"
ReadOnly
=
"True"
SortExpression
=
"Srno"
UniqueName
=
"Srno"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"Category"
FilterControlWidth
=
"50px"
HeaderText
=
"Total/ COC/SOC"
SortExpression
=
"Category"
UniqueName
=
"Category"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"A_20"
DataType
=
"System.Int32"
FilterControlWidth
=
"50px"
HeaderText
=
"A_20"
SortExpression
=
"A_20"
UniqueName
=
"A_20"
>
<
HeaderStyle
Width
=
"80px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DataField
=
"A_40"
DataType
=
"System.Int32"
FilterControlWidth
=
"50px"
HeaderText
=
"A_40"
SortExpression
=
"A_40"
UniqueName
=
"A_40"
>
<
HeaderStyle
Width
=
"80px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DataField
=
"A_45"
DataType
=
"System.Int32"
FilterControlWidth
=
"50px"
HeaderText
=
"A_45"
SortExpression
=
"A_45"
UniqueName
=
"A_45"
>
<
HeaderStyle
Width
=
"80px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"Status"
FilterControlWidth
=
"50px"
HeaderText
=
"Status Open/Close"
SortExpression
=
"Status"
UniqueName
=
"Status"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"Time_Creation"
DataType
=
"System.DateTime"
FilterControlWidth
=
"110px"
HeaderText
=
"Time Creation"
SortExpression
=
"Time_Creation"
UniqueName
=
"Time_Creation"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"140px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"LastModified"
DataType
=
"System.DateTime"
FilterControlWidth
=
"110px"
HeaderText
=
"LastModified"
SortExpression
=
"LastModified"
UniqueName
=
"LastModified"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"140px"
/>
</
telerik:GridDateTimeColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
HeaderStyle
Wrap
=
"True"
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
BackColor
=
"Beige"
/>
<
FilterMenu
EnableEmbeddedScripts
=
"True"
> </
FilterMenu
>
<
FilterItemStyle
/>
<
HeaderContextMenu
EnableEmbeddedScripts
=
"False"
></
HeaderContextMenu
>
<
GroupingSettings
CaseSensitive
=
"False"
/>
<
ClientSettings
>
<
Resizing
EnableRealTimeResize
=
"True"
></
Resizing
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"True"
ScrollHeight
=
"550px"
FrozenColumnsCount
=
"3"
>
</
Scrolling
>
<
Resizing
EnableRealTimeResize
=
"True"
/>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
OnRowCreating
=
"RowCreating"
OnRowCreated
=
"RowCreated"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
div
>
</
asp:Content
>
Thanks and best regards.
0
Accepted
Hello naunt,
I tested the provided page and bound the grid using XmlDataSource control. In this case I was able to replicate the issue. You can overcome it by modifying the code as below:
Kind regards,
Iana
the Telerik team
I tested the provided page and bound the grid using XmlDataSource control. In this case I was able to replicate the issue. You can overcome it by modifying the code as below:
function
RowDblClick(sender, args) {
var
row = sender.get_masterTableView().get_dataItems()[args.get_itemIndexHierarchical()];
if
(sender.get_masterTableView().getCellByColumnUniqueName(row,
"Category"
).innerHTML !=
"T"
) {
// Check for the condition
sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
}
}
Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Naunton
Top achievements
Rank 1
answered on 27 Jan 2011, 05:03 AM
Dear Iana ,
Thank you so much. This work for me.
Thanks and best regards.
Thank you so much. This work for me.
Thanks and best regards.