What can be the reason for the textbox in the Batch Edit mode to be wider than a column itself (like in the attached image)?
Thank you,
Vadim
7 Answers, 1 is accepted
The presented issue is not an expected behavior in a sample batch editing configuration and could not be replicated on our side. You can test the online demo below that works properly:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx
Therefore it appears that the issue is related to your specific custom scenario. In such case it will be best if you can share your page markup as well as related code behind so that we can further investigate the presented issue.
Regards,
Maria Ilieva
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
<div id="demo" class="demo-container no-bg">
Could this be the reason?
Here's my entire page I created for testing. The data is retrieved on the code behind via a stored procedure call.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="TestWebApp.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
div
>
<
telerik:radgrid
ID
=
"rgListItems"
runat
=
"server"
AutoGenerateColumns
=
"false"
GridLines
=
"None"
Skin
=
"Office2010Blue"
AllowPaging
=
"false"
AllowSorting
=
"true"
Width
=
"700px"
OnNeedDataSource
=
"rgListItems_NeedDataSource"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
EditMode
=
"Batch"
HorizontalAlign
=
"NotSet"
DataKeyNames
=
"CustomListingId"
ClientDataKeyNames
=
"SortOrder"
AutoGenerateColumns
=
"false"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"true"
ShowCancelChangesButton
=
"true"
ShowRefreshButton
=
"true"
ShowSaveChangesButton
=
"false"
/>
<
BatchEditingSettings
EditType
=
"Cell"
/>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"SortOrder"
SortOrder
=
"Ascending"
/>
</
SortExpressions
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Label"
DataField
=
"Label"
UniqueName
=
"Label"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Description"
DataField
=
"Description"
/>
<
telerik:GridNumericColumn
HeaderText
=
"Sort Order"
DataField
=
"SortOrder"
UniqueName
=
"SortOrder"
HeaderStyle-Width
=
"100px"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Last Updated By"
DataField
=
"UpdateUser"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Last Updated On"
DataField
=
"UpdateDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Created On"
DataField
=
"CreateDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
ReadOnly
=
"true"
/>
<
telerik:GridButtonColumn
ButtonType
=
"LinkButton"
CommandName
=
"Delete"
UniqueName
=
"DeleteColumnListing"
Text
=
"Delete"
ConfirmText
=
"Delete this custom listing?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
HeaderText
=
"Delete"
HeaderStyle-Width
=
"50px"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:radgrid
>
</
div
>
</
form
>
</
body
>
</
html
>
Here's the code behind.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace TestWebApp
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private DataSet GetData()
{
DataSet oDS = new DataSet();
// [dbo].[proc_ADMIN_SEL_CustomFieldListing](@ai_i_CustomFieldId int)
using (SqlConnection oConn = new SqlConnection("Data Source=MDNDEV02;Initial Catalog=Vscript_Trans_DB;User Id=user;Password=pwd;"))
{
using (SqlCommand oCmd = new SqlCommand("proc_ADMIN_SEL_CustomFieldListing", oConn))
{
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.AddWithValue("@ai_i_CustomFieldId", 33);
using (SqlDataAdapter oDA = new SqlDataAdapter(oCmd))
{
oDA.Fill(oDS);
}
}
}
return oDS;
}
protected void rgListItems_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid RadGrid2 = (RadGrid)sender;
RadGrid2.DataSource = GetData();
}
}
}
Warren
Any help is greatly appreciated.
Warren
Note that the TextBox controls that are rendered when you are in edit mode are resized automatically by the browser. A possible solution is to set a 100% width of the TextBox controls. This approach could be achieved by setting hooking PreRender event handler and access the TextBox control from the BatchEditor. Please check out the following code snippet.
protected
void
rgListItems_PreRender(
object
sender, EventArgs e)
{
GridTableView masterTable = (sender
as
RadGrid).MasterTableView;
GridColumn descriptionColumn = masterTable.GetColumnSafe(
"Description"
)
as
GridColumn;
TextBox descriptionEditor = (masterTable.GetBatchColumnEditor(descriptionColumn)
as
GridTextBoxColumnEditor).TextBoxControl;
descriptionEditor.Width = Unit.Percentage(100);
}
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Can you please share your page markup and related code behind so that we can revise them locally and determine what the exact difference between them and the demo code is?
Regards,
Maria Ilieva
Telerik
This worked for me but I had to modify it so that it is converted to a radnumerictext box:
Dim masterTable As GridTableView = TryCast(sender, RadGrid).MasterTableView
Dim descriptionColumn As GridColumn = TryCast(masterTable.GetColumnSafe("CategoryValue"), GridColumn)
Dim descriptionEditor As RadNumericTextBox = TryCast(masterTable.GetBatchColumnEditor(descriptionColumn), GridNumericColumnEditor).NumericTextBox
descriptionEditor.Width = Unit.Percentage(100)