PDA

View Full Version : [CLOSED] GridPanel + sql_Variant data type



bossun
Oct 22, 2012, 7:53 AM
Hi,

How can I display sql_Variant column in a gridpanel?

In the page you can see below, both fileds DEFAULTVALUE and DOMAINLIST of the first store are sql_variant. Unfortunately these values are not displayed in the GridPanel whereas they are filled in the database.

Any idea?


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserAttributes.aspx.cs" Inherits="Web_UserAttributes" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">


<ext:XScript runat="server">
<script type="text/javascript">
var Init = function () {
#{AttributeFormEditor}.getForm().reset();
#{UserAttributesGridPanel}.getSelectionModel().des electAll(true);
#{DOMAINLIST}.setDisabled(true);
#{btnDelete}.setDisabled(true);
}

var DataTypeRenderer = function (value) {
var r = App.DataTypeStoreID.getById(value);

if (Ext.isEmpty(r)) {
return "";
}
return r.data.TRANSLATEDVALUE;
};

var DomainListRenderer = function (value) {
var r = App.DomainListStoreID.getById(value);
alert(value);
if (Ext.isEmpty(r)) {
return "";
}
return r.data.TRANSLATEDVALUE;
};

</script>
</ext:XScript>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server"></ext:ResourceManager>

<asp:ObjectDataSource ID="UserAttributesDataSource" runat="server"
SelectMethod="UserAttributeSelect"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportUserAttrib ute">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="DataTypeDatasource" runat="server" SelectMethod="ChoicesSelect_DataTypes"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportListAndCho ices">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="DomainListDataSource" runat="server" SelectMethod="ChoicesSelect_DomainLists"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportListAndCho ices">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

<ext:Store runat="server" ID="UserAttributesStoreID" DataSourceID="UserAttributesDataSource">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="ATTRIBUTENAME" Type="String" />
<ext:ModelField Name="TRANSLATEDVALUE" Type="String" />
<ext:ModelField Name="DATATYPE" Type="String" />
<ext:ModelField Name="DEFAULTVALUE" />
<ext:ModelField Name="DOMAINLIST" />
<ext:ModelField Name="ALLOWNULL" Type="Boolean" />
<ext:ModelField Name="VISIBLEBYUSER" Type="Boolean" />
<ext:ModelField Name="EDITABLEBYUSER" Type="Boolean" />
<ext:ModelField Name="ISSYSTEM" Type="Boolean" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="DataTypeStoreID" runat="server" DataSourceID="DataTypeDatasource">
<Model>
<ext:Model runat="server" IDProperty="KEY" ID="ctl238">
<Fields>
<ext:ModelField Name="KEY" Type="String" />
<ext:ModelField Name="VALUE" Type="String" />
<ext:ModelField Name="TRANSLATEDVALUE" Type="String" />
<ext:ModelField Name="ISSYSTEM" Type="Boolean" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="DomainListStoreID" runat="server" DataSourceID="DomainListDataSource">
<Model>
<ext:Model runat="server" IDProperty="ID" >
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="TRANSLATEDVALUE" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Viewport runat="server" Padding="5" Layout="BorderLayout">
<Items>
<ext:GridPanel runat="server"
ID="UserAttributesGridPanel"
Region="Center"
Padding="5"
Frame="true"
Split="true"
Width="200"
StoreID="UserAttributesStoreID"
Title="<%$ Resources:Resource,UserAttributes %>"
>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" DataIndex="ID" Text="<%$ Resources:Resource,Id %>" Width="50" Hidden="true" />
<ext:Column runat="server" DataIndex="ATTRIBUTENAME" Text="<%$ Resources:Resource,AttributeName %>" Flex="2" />
<ext:Column runat="server" DataIndex="TRANSLATEDVALUE" Text="<%$ Resources:Resource,TranslatedValue %>" Flex="2"/>
<ext:Column runat="server" DataIndex="DATATYPE" Text="<%$ Resources:Resource,DataType %>" Flex="1" >
<Renderer Fn="DataTypeRenderer" />
</ext:Column>
<ext:Column runat="server" DataIndex="DOMAINLIST" Text="<%$ Resources:Resource,DomainList %>" Flex="1" >
<Renderer Fn="DomainListRenderer" />
</ext:Column>
<ext:Column runat="server" DataIndex="DEFAULTVALUE" Text="<%$ Resources:Resource,DefaultValue %>" Flex="1" />
<ext:CheckColumn runat="server" DataIndex="ALLOWNULL" Text="<%$ Resources:Resource,AllowNull %>" Flex="1"/>
<ext:CheckColumn runat="server" DataIndex="VISIBLEBYUSER" Text="<%$ Resources:Resource,VisibleByUser %>" Flex="1"/>
<ext:CheckColumn runat="server" DataIndex="EDITABLEBYUSER" Text="<%$ Resources:Resource,EditableByUser %>" Flex="1"/>
<ext:CheckColumn runat="server" DataIndex="ISSYSTEM" Text="<%$ Resources:Resource,IsSystem %>" Flex="1"/>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="true">
<Listeners>
<Select Handler="#{AttributeFormEditor}.getForm().reset();" />
</Listeners>
<DirectEvents>
<Select OnEvent="RowSelect" Buffer="250">
<EventMask ShowMask="true" Target="CustomTarget" Msg="<%$ Resources:Resource,M_Wait_Loading %>"
CustomTarget="#{AttributeFormEditor}" />
<ExtraParams>
<ext:Parameter Name="ID" Value="record.getId()" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>


<ext:FormPanel
ID="AttributeFormEditor"
Title="<%$ Resources:Resource,LeagueEditor %>"
runat="server"
Region="East"
Width="350"
Split="true"
Frame="true"
BodyPadding="10"
MonitorValid="true"
>
<Defaults>
<ext:Parameter Name="anchor" Value="95%" Mode="Value" />
</Defaults>
<Items>
<ext:Hidden ID="ID" runat="server" DataIndex="ID" />
<ext:DisplayField ID="labelID" runat="server" DataIndex="ID" FieldLabel="<%$ Resources:Resource,Id %>" />
<ext:TextField ID="ATTRIBUTENAME" runat="server" DataIndex="ATTRIBUTENAME" FieldLabel="<%$ Resources:Resource,AttributeName %>" AllowBlank="false" />
<ext:NumberField ID="TRANSLATEKEY" runat="server" DataIndex="TRANSLATEKEY" FieldLabel="<%$ Resources:Resource,TranslateKey %>" />
<ext:ComboBox ID="DATATYPE" runat="server" StoreID="DataTypeStoreID" ValueField="KEY" DisplayField="TRANSLATEDVALUE" FieldLabel="<%$ Resources:Resource, DataType %>" MsgTarget="Side" AllowBlank="false" EmptyText="<%$ Resources:Resource, DataType %>"/>
<ext:ComboBox ID="DOMAINLIST" runat="server" StoreID="DomainListStoreID" ValueField="ID" DisplayField="TRANSLATEDVALUE" FieldLabel="<%$ Resources:Resource, DomainList %>" MsgTarget="Side" AllowBlank="false" EmptyText="<%$ Resources:Resource, DomainList %>" />
<ext:TextField ID="DEFAULTVALUE" runat="server" DataIndex="DEFAULTVALUE" FieldLabel="<%$ Resources:Resource,DefaultValue %>" AllowBlank="true" />
<ext:Checkbox ID="ALLOWNULL" runat="server" DataIndex="ALLOWNULL" FieldLabel="<%$ Resources:Resource,AllowNull %>" />
<ext:Checkbox ID="VISIBLEBYUSER" runat="server" DataIndex="VISIBLEBYUSER" FieldLabel="<%$ Resources:Resource,VisibleByUser %>" />
<ext:Checkbox ID="EDITABLEBYUSER" runat="server" DataIndex="EDITABLEBYUSER" FieldLabel="<%$ Resources:Resource,EditableByUser %>" />
<ext:Checkbox ID="ISSYSTEM" runat="server" DataIndex="ISSYSTEM" FieldLabel="<%$ Resources:Resource,IsSystem %>" ReadOnly="true" />
</Items>
<Listeners>
<ValidityChange Handler="#{btnSave}.setDisabled(!valid);" />
</Listeners>
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btnInit" runat="server" Text="<%$ Resources:Resource,Initialise %>"
Icon="Add">
<Listeners>
<Click Fn="Init" />
</Listeners>
</ext:Button>
<ext:ToolbarSeparator runat="server" />
<ext:Button ID="btnSave" runat="server" FormBind="true" Text="<%$ Resources:Resource,Save %>" Icon="DiskEdit">
<DirectEvents>
<Click OnEvent="BtnSaveUserAttribute_Click" Buffer="250">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{AttributeFormEditor}"
Msg="<%$ Resources:Resource,M_Wait_Saving %>" />
<ExtraParams>
<ext:Parameter Name="UserAttributeRecord" Mode="Raw" Encode="true" Value="#{AttributeFormEditor}.getForm().getValues()">
</ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
<ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server" />
<ext:Button ID="btnDelete" runat="server" Text="<%$ Resources:Resource,Delete %>"
Icon="Delete" Disabled="true">
<DirectEvents>
<Click OnEvent="BtnDeleteUserAttribute_Click" Buffer="250" Before="">
<Confirmation Message="<%$ Resources:Resource,M_Confirm_Delete %>" ConfirmRequest="true" />
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{AttributeFormEditor}"
Msg="<%$ Resources:Resource,M_Wait_Delete %>" />
<ExtraParams>
<ext:Parameter Name="UserAttributeRecord" Mode="Raw" Encode="true" Value="#{LeaguesFormEditor}.getForm().getValues()">
</ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:FormPanel>

</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>


Thank you very much

Daniil
Oct 22, 2012, 9:04 AM
Hi @bossun,


whereas they are filled in the database.


But are they retrieved by the UserAttributeSelect SelectMethod and come to the ObjectDataSource?

Also please check the Page Sources, can you see these data rendered?

bossun
Oct 22, 2012, 9:56 AM
Hello Daiiil,

Thank you for your reply



But are they retrieved by the UserAttributeSelect SelectMethod and come to the ObjectDataSource?


Yes of course.




Also please check the Page Sources, can you see these data rendered?


No they are not rendered. I'll try to cast all data to string and see if changes something.

Vladimir
Oct 22, 2012, 10:06 AM
What return type of UserAttributeSelect method? How that sql field is defined in that return type (is that property? if yes then what kind of type?) ?

bossun
Oct 22, 2012, 11:54 AM
UserAttributeSelect returns a DataTable.

It seems that sql_variant type is not supported. Perhaps a bug?

When selecting the data I casted the DEFAULTVALUE field to varchar and all values are shown in my gridpanel.

Vladimir
Oct 22, 2012, 12:28 PM
Well, you can try to set IsComplex=true for that ModelField but i am not sure that it will help
Another suggestion, convert datatable to list of objects, just extract required info manually

bossun
Oct 23, 2012, 9:49 PM
Well, you can try to set IsComplex=true for that ModelField but i am not sure that it will help
Another suggestion, convert datatable to list of objects, just extract required info manually


Hi Vladimir,

IsComplex=true fixed my issue.

Thank you very much