Hi Team,
I am using the telerik dll version of 2014.2.724.45
I am facing one issue while editing the grid.
Let me explain the issue.
I have a grid with 5 columns in it and has some data populated. I am implementing batch editing(with batch editing type=cell) for this grid.
When I click on the add new record I am inserting a new row, here I don't have any issue.
While updating the record I want to make one column non editable, other columns are editable.
How can I achieve this.Please see the aspx and .cs files below
ASPX FILE:
<telerik:RadGrid ID="DischargeRadGrid" OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
CssClass="TransferGridPanel" Height="370px" Width="500px" OnItemCommand="DischargeRadGrid_ItemCommand"
OnBatchEditCommand="DischargeRadGrid_BatchEditCommand">
<MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Discharge_ID">
<CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
<BatchEditingSettings EditType="Cell" />
<Columns>
<telerik:GridBoundColumn UniqueName="DeliveryNo" DataField="Discharge_ID">
<ColumnValidationSettings EnableRequiredFieldValidation="true">
<RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
</RequiredFieldValidator>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ShipTo"
DataField="Site_ID">
<ColumnValidationSettings EnableRequiredFieldValidation="true">
<RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
</RequiredFieldValidator>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ShipToName"
DataField="SiteAddress" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DischargeStart"
DataField="DischargeStartTime" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DischargeEnd"
DataField="DischargeEndTime">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="true"/>
</ClientSettings>
</telerik:RadGrid>
ASPX.CS FILE
protected void DischargeRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
{
foreach (GridBatchEditingCommand command in e.Commands)
{
Hashtable newValues = command.NewValues;
Hashtable oldValues = command.OldValues;
string newDischargeId = newValues["Discharge_ID"].ToString();
string newShipTo = newValues["Site_ID"].ToString();
DateTime? dischargeStartTime = DateTime.Now;
DateTime? dischargeEndTime = DateTime.Now;
Int32 dropindex;
Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
dropindex = dischargeManager.GetDropIndexCountByDishargeId(shipmentID);
List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
dischargeDetails = dischargeManager.GetDischargeByShipmentId(shipmentID);
if (command.Type == GridBatchEditingCommandType.Update)
{
RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_UPDATE_LOAD), "confirmCallBackFn", 400, 100, null, null);
var DischargeDal = new DischargeDal();
var discharge = new DischargeEntity
{
Discharge_ID = Convert.ToInt64(newDischargeId),
Site_ID = Convert.ToInt64(newShipTo),
Job_ID = new Guid(),
Shipment_ID = shipmentID,
Planned = false,
DropIndex = dropindex,
Urgency = dischargeDetails[0].Urgency,
DischargeStartTime = dischargeStartTime,
DischargeEndTime = dischargeEndTime, };
discharge.Discharge_ID = DischargeDal.UpdateDischargeByDischargeId(discharge).Discharge_ID;
dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
DischargeRadGrid.DataSource = dischargeDetailWsList;
DischargeRadGrid.DataBind();
}
if (command.Type == GridBatchEditingCommandType.Insert)
{
RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_ADD_NEW_LOAD), "confirmCallBackFn", 400, 100, null, null);
List<DischargeEntity> currentList = (List<DischargeEntity>)Session[_sesDischargeList];
DischargeEntity de = currentList[0];
var DischargeDal = new DischargeDal();
if(!(Boolean)de.Planned)
{
}
var discharge = new DischargeEntity
{
Job_ID = new Guid(),
Discharge_ID = Convert.ToInt64(newDischargeId),
Shipment_ID = shipmentID,
DropIndex = dropindex,
Site_ID = Convert.ToInt64(newShipTo),
Planned = false,
PONumber = dischargeDetails[0].PONumber,
Urgency = dischargeDetails[0].Urgency,
DischargeStartTime = dischargeStartTime,
DischargeEndTime=dischargeEndTime,
};
discharge.Discharge_ID = DischargeDal.CreateDischarge(discharge).Discharge_ID;
dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
DischargeRadGrid.DataSource = dischargeDetailWsList;
DischargeRadGrid.DataBind();
}
if (command.Type == GridBatchEditingCommandType.Delete)
{
//perform delete
}
}
}
Please send me the answer asap.it is very urgent.
Thanks in advance.
I am using the telerik dll version of 2014.2.724.45
I am facing one issue while editing the grid.
Let me explain the issue.
I have a grid with 5 columns in it and has some data populated. I am implementing batch editing(with batch editing type=cell) for this grid.
When I click on the add new record I am inserting a new row, here I don't have any issue.
While updating the record I want to make one column non editable, other columns are editable.
How can I achieve this.Please see the aspx and .cs files below
ASPX FILE:
<telerik:RadGrid ID="DischargeRadGrid" OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
CssClass="TransferGridPanel" Height="370px" Width="500px" OnItemCommand="DischargeRadGrid_ItemCommand"
OnBatchEditCommand="DischargeRadGrid_BatchEditCommand">
<MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Discharge_ID">
<CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
<BatchEditingSettings EditType="Cell" />
<Columns>
<telerik:GridBoundColumn UniqueName="DeliveryNo" DataField="Discharge_ID">
<ColumnValidationSettings EnableRequiredFieldValidation="true">
<RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
</RequiredFieldValidator>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ShipTo"
DataField="Site_ID">
<ColumnValidationSettings EnableRequiredFieldValidation="true">
<RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
</RequiredFieldValidator>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ShipToName"
DataField="SiteAddress" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DischargeStart"
DataField="DischargeStartTime" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DischargeEnd"
DataField="DischargeEndTime">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="true"/>
</ClientSettings>
</telerik:RadGrid>
ASPX.CS FILE
protected void DischargeRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
{
foreach (GridBatchEditingCommand command in e.Commands)
{
Hashtable newValues = command.NewValues;
Hashtable oldValues = command.OldValues;
string newDischargeId = newValues["Discharge_ID"].ToString();
string newShipTo = newValues["Site_ID"].ToString();
DateTime? dischargeStartTime = DateTime.Now;
DateTime? dischargeEndTime = DateTime.Now;
Int32 dropindex;
Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
dropindex = dischargeManager.GetDropIndexCountByDishargeId(shipmentID);
List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
dischargeDetails = dischargeManager.GetDischargeByShipmentId(shipmentID);
if (command.Type == GridBatchEditingCommandType.Update)
{
RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_UPDATE_LOAD), "confirmCallBackFn", 400, 100, null, null);
var DischargeDal = new DischargeDal();
var discharge = new DischargeEntity
{
Discharge_ID = Convert.ToInt64(newDischargeId),
Site_ID = Convert.ToInt64(newShipTo),
Job_ID = new Guid(),
Shipment_ID = shipmentID,
Planned = false,
DropIndex = dropindex,
Urgency = dischargeDetails[0].Urgency,
DischargeStartTime = dischargeStartTime,
DischargeEndTime = dischargeEndTime, };
discharge.Discharge_ID = DischargeDal.UpdateDischargeByDischargeId(discharge).Discharge_ID;
dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
DischargeRadGrid.DataSource = dischargeDetailWsList;
DischargeRadGrid.DataBind();
}
if (command.Type == GridBatchEditingCommandType.Insert)
{
RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_ADD_NEW_LOAD), "confirmCallBackFn", 400, 100, null, null);
List<DischargeEntity> currentList = (List<DischargeEntity>)Session[_sesDischargeList];
DischargeEntity de = currentList[0];
var DischargeDal = new DischargeDal();
if(!(Boolean)de.Planned)
{
}
var discharge = new DischargeEntity
{
Job_ID = new Guid(),
Discharge_ID = Convert.ToInt64(newDischargeId),
Shipment_ID = shipmentID,
DropIndex = dropindex,
Site_ID = Convert.ToInt64(newShipTo),
Planned = false,
PONumber = dischargeDetails[0].PONumber,
Urgency = dischargeDetails[0].Urgency,
DischargeStartTime = dischargeStartTime,
DischargeEndTime=dischargeEndTime,
};
discharge.Discharge_ID = DischargeDal.CreateDischarge(discharge).Discharge_ID;
dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
DischargeRadGrid.DataSource = dischargeDetailWsList;
DischargeRadGrid.DataBind();
}
if (command.Type == GridBatchEditingCommandType.Delete)
{
//perform delete
}
}
}
Please send me the answer asap.it is very urgent.
Thanks in advance.