PDA

View Full Version : How to upload table into ext:gridpanel / ext:gridview ?



neosaint
Jun 08, 2014, 12:35 PM
Hi All,

Need your help please, how to upload / show data from table masterdata into ext:gridview from the code behind?

thanks a lot.

Daniil
Jun 09, 2014, 12:42 PM
Hi @neosaint,

You should do the following in code behind.

store.DataSource = data;
store.DataBind();

neosaint
Jun 09, 2014, 2:32 PM
Hi @daniil,
12361
Please find my code :



<ext:FieldSet ID="FieldSet1"
runat="server"
Collapsible="true"
Title="Recipe Components"
Layout="FitLayout">
<Defaults>
<ext:Parameter Name="LabelWidth" Value="100" Mode="Raw" />
</Defaults>
<Items>
<ext:GridPanel ID="GridPanel1" runat="server" Header="false" Border="false" >
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="clitemno" runat="server" Text="Item No" Width="100" Sortable="true" DataIndex="itemno" />
<ext:Column ID="clitemname" runat="server" Text="Item Name" Sortable="true" DataIndex="itemnm" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" />
</View>
<Features>
<ext:GridFilters ID="GridFilters1" runat="server" Local="true">
<Filters>
<ext:StringFilter DataIndex="itemno" />
<ext:StringFilter DataIndex="itemnm" />
</Filters>
</ext:GridFilters>
</Features>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" DisplayInfo="true" DisplayMsg="Displaying Jobs {0} - {1} of {2}" />
</BottomBar>
</ext:GridPanel>
</Items>
</ext:FieldSet>


And my Code Behind:



Private Sub gridview_show()
Dim myStore As New Ext.Net.Store
Dim c1 As String = "SELECT id,itemno,itemnm,qty,itemuom,itemuomnm from rcptdtl where id=16"
Dim obj As New sqlhelperitn.Class1
Dim dt As New DataTable
Dim dv As New DataView

dt = obj.executedatatable(c1)

myStore.DataSource = dt
myStore.DataBind()

GridPanel1.Store.Add(myStore)
GridPanel1.DataBind()
dv = dt.DefaultView
GridView1.Data = dv
GridView1.DataBind()
GridView1.DataBind()

End Sub


Could you please explain to us how to solve this issue?

Thanks.


Hi @neosaint,

You should do the following in code behind.

store.DataSource = data;
store.DataBind();

Daniil
Jun 09, 2014, 4:00 PM
Please provide a full and runnable test case. Please remove dependance from the database creating a fake DataTable for the sake of testing.

neosaint
Jun 10, 2014, 3:12 AM
Hi @daniil,

Please find the full script below: Thanks in advanced.



<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="wfrcptform.aspx.vb" Inherits="CW.wfrcptform" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CPHBody" runat="server">

<ext:FieldSet ID="FieldSet1"
runat="server"
Collapsible="true"
Title="Recipe Components"
Layout="FitLayout">
<Defaults>
<ext:Parameter Name="LabelWidth" Value="100" Mode="Raw" />
</Defaults>
<Items>
<ext:GridPanel ID="GridPanel1" runat="server" Header="false" Border="false" >
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="clitemno" runat="server" Text="Item No" Width="100" Sortable="true" DataIndex="itemno" />
<ext:Column ID="clitemname" runat="server" Text="Item Name" Sortable="true" DataIndex="itemnm" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" />
</View>
<Features>
<ext:GridFilters ID="GridFilters1" runat="server" Local="true">
<Filters>
<ext:StringFilter DataIndex="itemno" />
<ext:StringFilter DataIndex="itemnm" />
</Filters>
</ext:GridFilters>
</Features>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" DisplayInfo="true" DisplayMsg="Displaying Jobs {0} - {1} of {2}" />
</BottomBar>
</ext:GridPanel>
</Items>
</ext:FieldSet>
</Items>
</ext:Panel>
</asp:Content>


The Code Behind:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
gridview_show()
End If
End Sub

Private Sub gridview_show()
Dim myStore As New Ext.Net.Store
Dim c1 As String = "SELECT id,itemno from masterdata"
Dim obj As New sqlhelperitn.Class1
Dim dt As New DataTable
Dim dv As New DataView

dt = obj.executedatatable(c1)

myStore.DataSource = dt
myStore.DataBind()

GridPanel1.Store.Add(myStore)
GridPanel1.DataBind()
dv = dt.DefaultView
GridView1.Data = dv
GridView1.DataBind()
GridView1.DataBind()

End Sub



Please provide a full and runnable test case. Please remove dependance from the database creating a fake DataTable for the sake of testing.

Daniil
Jun 10, 2014, 5:18 AM
Please re-read.

Please remove dependance from the database creating a fake DataTable for the sake of testing.

Also please get rid of a master page and put the code behind directly into the .aspx page wrapping in

<script runat="server">
</script>

Please look at Example (Very Helpful) here:
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)

neosaint
Jun 10, 2014, 10:08 AM
Hi @daniil,

SOLVED already. Thanks.

I forget to put storeid in the source. thanks.


Please re-read.


Also please get rid of a master page and put the code behind directly into the .aspx page wrapping in

<script runat="server">
</script>

Please look at Example (Very Helpful) here:
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)