2012-08-23 2 views
0

ext.net에 새로 왔습니다.편집 가능한 격자 패널과 함께 entitydatasource 사용

<asp:EntityDataSource ID="EntityDataSource1" runat="server" 
      AutoGenerateOrderByClause="True" 
      ConnectionString="name=Sample1Entities" 
      DefaultContainerName="Sample1Entities" 
      EnableDelete="True" 
      EnableFlattening="False" 
      EnableInsert="True" 
      EnableUpdate="True" 
      EntitySetName="Customer" 
      EntityTypeFilter="Customer" 
      OnUpdating="EntityDataSource1_OnUpdating" 
     > 
<ext:GridPanel 
      runat="server" 
      ID="GridPanel1" 
      Height="570" 
      Title="Customers" 
      Frame="true"> 
      <Store> 
       <ext:Store ID="Store1" runat="server" DataSourceID="EntityDataSource1" AutoSync="true" 
        IDMode="Client"> 
        <Model> 
         <ext:Model ID="Model1" runat="server"> 
          <Fields> 
           <ext:ModelField Name="CustomerId" Mapping="CustomerId" /> 
           <ext:ModelField Name="Name" /> 
           <ext:ModelField Name="Surname" /> 
          </Fields> 
         </ext:Model> 
        </Model> 
       </ext:Store> 
      </Store> 
      <ColumnModel ID="ColumnModel1" runat="server"> 
       <Columns> 
        <ext:Column ID="Column1" runat="server" DataIndex="CustomerId" Text="CustomerId" Width="150" /> 
        <ext:Column ID="Column2" runat="server" DataIndex="Name" Text="Name" Width="150"> 
         <Editor> 
          <ext:TextField runat="server" ></ext:TextField> 
         </Editor> 
        </ext:Column> 
        <ext:Column ID="Column3" runat="server" DataIndex="Surname" Text="Surname" Width="150" /> 
       </Columns> 
      </ColumnModel>  
      <SelectionModel> 
       <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" /> 
      </SelectionModel> 
      <Plugins> 
       <ext:CellEditing ID="CellEditing1" runat="server" /> 
      </Plugins> 
     </ext:GridPanel> 

엔티티 클래스에 아무 문제가 없습니다 : 내가 여기

entitydatasource

를 사용하여 편집 가능한 격자를 만들기 위해 시도하고 코드입니다. 내가 자동으로 db에서 그것을 생성하고 테스트했습니다. 내가 이름 열을 편집 할 때 는 오류 다음 제공 :

System.Exception: The key-value pairs that define an EntityKey cannot be null or empty.\r\n 
Parameter name: record ---> System.ArgumentException: The key-value pairs that define an EntityKey cannot be null or empty.\r\n 
Parameter name: record\r\n 
at System.Data.EntityKey.CheckValue(String argumentName, String keyFieldName, Object value, PrimitiveType expectedType)\r\n 
at System.Data.EntityKey.CheckKeyValues(EntitySet entitySet, IExtendedDataRecord record, String[]& keyNames, Object& singletonKeyValue, Object[]& compositeKeyValues)\r\n 
at System.Data.EntityKey..ctor(EntitySet entitySet, IExtendedDataRecord record)\r\n at System.Data.Objects.ObjectStateManager.FixupKey(EntityEntry entry)\r\n at System.Data.Objects.EntityEntry.AcceptChanges()\r\n at System.Data.Objects.ObjectContext.AcceptAllChanges()\r\n at System.Web.UI.WebControls.EntityDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)\r\n at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback)\r\n at Ext.Net.Store.MakeUpdates(IDataSource ds, JArray data) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 890\r\n at Ext.Net.Store.MakeChanges() in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 829\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 793\r\n --- End of inner exception stack trace ---\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 806\r\n at Ext.Net.Store.RaiseAjaxPostBackEvent(String eventArgument) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 1131 

내가 아약스 요청 다음 gridpanel의 휴대 저장 전송을 편집 할 때;

submitDirectEventConfig:{"config":{"serviceParams":"[{\"CustomerId\":\"3   \",\"Name\":\"e\",\"Surname\":\"soyad1 \",\"id\":null}]"}} 
RowSelectionModel1:[{"RecordID":null,"RowIndex":2}] 
__EVENTTARGET:ResourceManager1 
__EVENTARGUMENT:Store1|postback|updat 

전자

감사

답변

0

또 다른 단계는 태그의 "IdPropery"속성을 발견하고

<ext:Model ID="Model1" runat="server" IDPropery="CompanyId"> 

그런 다음 이전의 예외를 통과 "회사 ID"값을 할당합니다. 이제 아래에서이 예외를 제공합니다.

System.Exception: Error while setting property 'id': 'Object of type 'System.Int32' cannot be converted to type 'System.String'.'. ---> System.Web.UI.WebControls.EntityDataSourceValidationException: Error while setting property 'id': 'Object of type 'System.Int32' cannot be converted to type 'System.String'.'.\r\n 
at System.Web.UI.WebControls.EntityDataSourceUtil.SetAllPropertiesWithVerification(EntityDataSourceWrapper entityWrapper, Dictionary`2 changedProperties, Boolean overwrite)\r\n 
at System.Web.UI.WebControls.EntityDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)\r\n 
at 
.... 

모델의 문자열 ID 필드를 사용할 수있는 방법이 있습니까?

0

Finaly 나는 ext.net 소스 코드를 수정 했으므로 오류가 발생합니다. store.cs에서 코드를 다음과 같이 변경했습니다.

 if (id.IsNotEmpty()) 
     { 
      string idStr = token.Value<string>(id); 

      int idInt; 

      if (int.TryParse(idStr, out idInt) && 1==0) // disable this logic 
      { 
       keys[id] = idInt; 
      } 
      else 
      { 
       keys[id] = idStr; 
      } 
     } 

이 솔루션이 도움이되기를 바랍니다.

관련 문제