PDA

View Full Version : [CLOSED] Store.GetAt(intRecordId).Set("State", (object)strState) fails on pagination



arjunrvasisht
Dec 29, 2014, 3:57 AM
We have recently migrated from V1.x to V2.x, as a part of this migration we have converted CommandColumn to ImageCommandColumn, now we are facing an issue after clicking on one of the images in the grid panel, we need to update the store fields with data values returned from DB. We are using this piece of code to do the same.


private void UpdateStoreAndRefreshGrid(Ext.Net.Store passedStoreId, Ext.Net.GridPanel passedGridPanelId, string strCommentId, int intRecordId, string strCommentText, string strState)
{
passedStoreId.GetAt(intRecordId).Set("State", (object)strState);
passedStoreId.GetAt(intRecordId).Set("Comments_Copy", (object)strCommentText);
if (!string.IsNullOrEmpty(strCommentId))
{
passedStoreId.GetAt(intRecordId).Set((object)strCo mmentId);
}
passedStoreId.CommitChanges();
passedGridPanelId.Refresh();
}

This code works fine in V1.x even with pagination and command column, however, for V2.x it fails after moving to 2nd page and clicking on image button with message Store.getAt() is null. The same code will work if we remove the pagianation all together. How to resolve this?

Daniil
Dec 29, 2014, 5:49 AM
Hi @arjunrvasisht,

I am afraid we cannot help after a test case to reproduce. Please provide.

arjunrvasisht
Dec 29, 2014, 6:10 AM
<ext:XScript ID="XScriptdd1" runat="server">

<script type="text/javascript">

var PrepareImgCommand = function (grid, command, record, row)
{
var IsTier1IOnlySelected =#{HdnIsTier1IOnlySelected}.getValue();
var IsControlEnable =#{HdnIsControlEnable}.getValue();
var yes = "1";
var NewComment='',ExistingComment='';
var IsTrimmed = false;
var iConCls = "cls-ico-defaultmode";

if(IsControlEnable == "1")
{
if (IsTier1IOnlySelected != yes)
{
if (command.command == "Submit" && record.get("State") !='' )
{
if (record.get("Comments")!= null || record.get("Comments") != undefined)
{
NewComment = record.get("Comments").trim();
IsTrimmed = true;
}
if (record.get("Comments_Copy")!= null || record.get("Comments_Copy") != undefined)
{
ExistingComment = record.get("Comments_Copy").trim();
IsTrimmed = true;
}

if ( record.get("State") == 'Draft')
{
if (NewComment == ExistingComment && NewComment != "")
{
if (record.get("Comments")!= null || record.get("Comments") != undefined)
{
command.iconCls = "cls-ico-draftmode";
}
}
else
{
command.iconCls = "cls-ico-defaultmode";
}
}
else if (record.get("State") == 'Submitted')
{
if (NewComment == ExistingComment)
{
command.iconCls = "cls-ico-submitmode";
}
else
{
command.iconCls = "cls-ico-defaultmode";
}
}
else
{
command.iconCls = iConCls;
}
}
else if (command.command == "PickList" && (record.get("Picklist_Flag") == 1 || record.get("PicklistFlag") == 1))
{
command.disabled = false;
if (IsTrimmed)
{
record.set("Comments",NewComment);
}
}
}
else
{
if (command.command == "Submit")
{
command.hidden = true;
}
if ( command.command == "PickList")
{
if (record.get("Picklist_Flag") == 0 || record.get("Picklist_Flag") == '' || record.get("PicklistFlag") == 0 || record.get("PicklistFlag") == '')
{
command.disabled =true;
}
else
{
command.disabled = false;
}
if (IsTrimmed)
{
record.set("Comments",NewComment);
}
}
}
}
else if(IsControlEnable == "2")
{
if ( command.command == "Submit")
{
command.hidden = true;
}

if ( command.command == "PickList")
{
if (record.get("Picklist_Flag") == 0 || record.get("Picklist_Flag") == '' || record.get("PicklistFlag") == 0 || record.get("PicklistFlag") == '') {
command.disabled =true;
}
else
{
command.disabled = false;
}
}
else
{
command.disabled =true;
}
}

};

</script>
</ext:XScript>

<script type="text/javascript" language="javascript">
function SubmitSPI(record)
{
Ext.net.DirectMethods.SubmitSelectedMetricComments 10,record.data.ProgramId,record.data.CommentId,rec ord.data.Comments,'-',record.index,record.data.Comments_Copy,record.da ta.State,record.data.ProjectId,record.data.CamId,r ecord.data.Tier4Id);
}
</script>

<ext:Store ID="StoreSPIComments" runat="server" OnReadData="StoreSPIComments_ReadData" WarningOnDirty="false" IsPagingStore="true" PageSize="10">
<Model>
<ext:Model IDProperty="CommentId" runat="server">
<Fields>
<ext:ModelField Name="CommentId" Type="String" />
<ext:ModelField Name="ProgramId" Type="String" />
<ext:ModelField Name="Comments_Copy" Type="String" />
<ext:ModelField Name="State" Type="String" />
<ext:ModelField Name="Tier4Id" Type="String" />
<ext:ModelField Name="Comments" Type="String" />
<ext:ModelField Name="Value" />
<ext:ModelField Name="Value_H" />
<ext:ModelField Name="SPI_FC" />
<ext:ModelField Name="T2" />
<ext:ModelField Name="T3" />
<ext:ModelField Name="T4" />
<ext:ModelField Name="kEyCode" />
<ext:ModelField Name="ProgramName" />
<ext:ModelField Name="ProjectName" />
<ext:ModelField Name="PE_Name" SortType="AsUCString" />
<ext:ModelField Name="PicklistFlag" />
<ext:ModelField Name="UnAssignedAlert" />
<ext:ModelField Name="ProjectId" Type="String" />
<ext:ModelField Name="CamId" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel ID="GrdPnlSPIComments" runat="server" StoreID="StoreSPIComments" EnableColumnMove="false"
ButtonAlign="Center" Height="250px" Width="1230" EnableColumnResize="true">
<Plugins>
<ext:CellEditing ID="ceSPIComments" ClicksToEdit="1" runat="server" />
</Plugins>
<ColumnModel>
<Columns>
<ext:ImageCommandColumn runat="server" Width="30" ID="GrdPnlSPIComments_CamIndicator" Text="" Cls="camImgMargin">
<Commands>
<ext:ImageCommand CommandName="UnAssignedCAM" Icon="Error">
<ToolTip Text="<%$ Resources:WebResource,GeneralMsg_TooltipForUnassig ned %>" />
</ext:ImageCommand>
</Commands>
<PrepareCommand Fn="UnAssignedCAMIndicator" />
</ext:ImageCommandColumn>
<ext:Column runat="server" DataIndex="Value" Text="SPI" Width="70" Sortable="true" MenuDisabled="true"
Resizable="false" Align="Center" ID="GrdPnlSPIComments_SPI">
<Renderer Fn="SpiHealth_Render" />
</ext:Column>
<ext:Column runat="server" DataIndex="T2" Text="T2" Width="80" Sortable="true" MenuDisabled="true"
Css="text-align:left;" Resizable="false" ID="GrdPnlSPIComments_T2" />
<ext:Column runat="server" DataIndex="T3" Text="T3" Width="110" Sortable="true" MenuDisabled="true"
Css="text-align:left;word-break:break-all;" Resizable="false" ID="GrdPnlSPIComments_T3" />
<ext:Column runat="server" DataIndex="T4" Text="T4" Width="110" Sortable="true" MenuDisabled="true"
Css="text-align:left;word-break:break-all;" Resizable="false" ID="GrdPnlSPIComments_T4" />
<ext:Column runat="server" DataIndex="kEyCode" Text="Keycode" Width="60" Sortable="true" MenuDisabled="true"
Resizable="false" Css="text-align:left;word-break:break-all;" ID="GrdPnlSPIComments_kEyCode" />
<ext:Column runat="server" DataIndex="ProgramName" Text="Program Name" Width="130" Sortable="true"
MenuDisabled="true" Resizable="false" Css="text-align:left;word-break:break-all;"
ID="GrdPnlSPIComments_ProgramName" />
<ext:Column runat="server" DataIndex="ProjectName" Text="Project" Width="130" Sortable="true"
MenuDisabled="true" Resizable="false" Css="text-align:left;word-break:break-all;"
ID="GrdPnlSPIComments_Project" />
<ext:Column runat="server" DataIndex="PE_Name" Text="PE Name" Width="100" Sortable="true" MenuDisabled="true"
Resizable="false" Css="text-align:left;word-break:break-all;" ID="GrdPnlSPIComments_PEName" />
<%--APPP-3408 - PN :-> V1.6 Removed Sorting for Comments column--%>
<ext:Column runat="server" DataIndex="Comments" Text="Comment (500 char max)" Width="277" Sortable="false"
MenuDisabled="true" Resizable="false" Cls="text-align:left;" ID="GrdPnlSPIComments_Comments">
<Editor>
<ext:TextArea ID="TxtSpiComments" runat="server" MaxLength="500" Grow="true" GrowMin="63"
GrowMax="150" MaskRe="[^<>]" StyleSpec="position:absolute;">
</ext:TextArea>
</Editor>
<Renderer Fn="CommentsColumn_Render" />
</ext:Column>
<ext:ImageCommandColumn runat="server" Width="90" Align="Center" ID="GrdPnlSPIImgComments_PickList" Resizable="false" MenuDisabled="true">
<Commands>
<ext:ImageCommand CommandName="PickList" IconCls="cls-ico-picklist" Disabled="true">
<ToolTip Text="<%$ Resources:WebResource,Picklist_ToolTip %>" />
</ext:ImageCommand>
<ext:ImageCommand CommandName="Submit" IconCls="cls-ico-defaultmode">
<ToolTip Text="<%$ Resources:WebResource,Submit_ToolTip %>" />
</ext:ImageCommand>
</Commands>
<PrepareCommand Fn="PrepareImgCommand" />
<Listeners>
<Command Handler="if(command == 'PickList') { #{HdnMetricsSelected}.setValue(10); #{HdnMetricsRowId}.setValue(record.index); Ext.net.DirectMethods.MetricsCommentsPicklist_Clic k(10,record.data.ProgramId,record.data.CommentId,r ecord.data.ProjectId,record.data.CamId,'-1'); } else if(command=='Submit') { SubmitSPI(record); } " />
</Listeners>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GrdViewSPIComments" runat="server" MarkDirty="false" TrackOver="false" StripeRows="false" />
</View>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:ToolbarFill />
<ext:Button ID="btnSpiCommentSubmittAll" runat="server" Text="Submit All &nbsp;&nbsp;&nbsp;"
Icon="ApplicationGo" ToolTip="<%$ Resources:WebResource,SubmitAll_ToolTip %>">
<DirectEvents>
<Click OnEvent="MetricsCommentSubmittAll_Click">
<ExtraParams>
<ext:Parameter Name="parameter" Value="Ext.encode(#{GrdPnlSPIComments}.getRowsValues({sel ectedOnly:false}))"
Mode="Raw" />
<ext:Parameter Name="parameter1" Value="10" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<BottomBar>
<ext:PagingToolbar ID="PagingSpiComment" runat="server" DisplayInfo="true" DisplayMsg="Displaying {0} - {1} of {2}" EmptyMsg="<%$ Resources:WebResource,GeneralMsg_NoRecordsFound %>" />
</BottomBar>
<SelectionModel>
<ext:CellSelectionModel ID="csmSPI" runat="server" />
</SelectionModel>
</ext:GridPanel>

let me know you mail id Danill so that i can share you video also which might give you more idea on what i am trying to do.

Daniil
Dec 29, 2014, 3:15 PM
Unfortunately, we cannot run this code snippet. Please provide a full runnable test case.


let me know you mail id Danill so that i can share you video also which might give you more idea on what i am trying to do.

It is something against our policy. We provide the help publicly and do our best to keep everything public. If you want to share some video, please upload it to somewhere and provide us with a link. I understand you cannot show everything, I mean there might be some private information on video, but we don't really need this information. Please don't show any private information on a video.

Anyone from the Ext.NET community would be able to see that video and help you.

Although, even if we have that video, a runnable test case will be probably requited still. Again, I understand it might be difficult to extract it from your project. Maybe, this technique can help.
How to prepare a sample (http://forums.ext.net/showthread.php?13672&p=56687&viewfull=1#post56687)