Click here to Skip to main content
13,555,747 members

TextBox in Header Template EXT.NET gridview

ancientrd asked:

Open original thread
I want to add a textbox in the header of a column and when keypress event on it is fired i need to use a function (not java) from my form. It must pass the textbox.text value to that fuction.I need it to make a search in the gridview.
I will want to add it in the filter and if i can take the event as StoreReadDataEventArgs . I BOLDED the code in where i need to catch the parameter.
How can i do that ? Thank you.
My code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
     <script type="text/javascript">
         var exportData = function (format) {
             var store =;
             store.submitData(null, { isUpload: true });
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1"  runat="server" />
         <ext:Hidden ID="FormatType"  runat="server" />
    <ext:GridPanel ID="GridPanel1"  runat="server" Height="400" Title="TESTE">
            <ext:Store id="Store1"  runat="server" RemoteSort="true"  buffered="true" PageSize="100" OnReadData="Store_ReadData"   önSubmitData="Store1_Submit"

                                <ext:JsonReader Root="data" />
                    <ext:Model  runat="server">
                            <ext:ModelField Name="line_id" Mapping="line_id"></ext:ModelField>
                            <ext:ModelField Name="cod" Mapping="cod"></ext:ModelField>
                             <ext:ModelField Name="tva" Mapping="tva"></ext:ModelField>
                        <ext:DataSorter Property="line_id" Direction="ASC" />

        <ColumnModel  runat="server" >
                <ext:RowNumbererColumn  runat="server" Width="50" Sortable="false"></ext:RowNumbererColumn>
                <ext:Column  runat="server" Text="line_id" DataIndex="line_id" Sortable="true"></ext:Column>
                <ext:Column  runat="server" Text="cod" DataIndex="cod" Sortable="true">
                         <ext:TextField ID="cod"  runat="server" EnableKeyEvents="true">
                                    <KeyUp Handler="#{Store_ReadData}"   />                                                
                <ext:Column  runat="server" Text="tva" DataIndex="tva" Sortable="true"></ext:Column>
            <ext:GridView  runat="server" TrackOver="false" ></ext:GridView>
            <ext:RowSelectionModel  runat="server" PruneRemoved="false" mode="Multi" ></ext:RowSelectionModel>
                <ext:Toolbar ID="Toolbar1"  runat="server">
                        <ext:ToolbarFill ID="ToolbarFill1"  runat="server" />
                        <ext:Button ID="Button1"  runat="server" Text="To XML" Icon="PageCode">
                                <Click Handler="exportData('xml');" />
                        <ext:Button ID="Button2"  runat="server" Text="To Excel" Icon="PageExcel">
                                <Click Handler="exportData('xls');" />
                        <ext:Button ID="Button3"  runat="server" Text="To CSV" Icon="PageAttach">
                                <Click Handler="exportData('csv');" />
                        <ext:GridFilters   runat="server" ID="gridfilters1">
                                <ext:StringFilter DataIndex="cod" />
                                <ext:listfilter DataIndex="tva" Options="0,9,24" />

        <ext:Label ID="Label2"  runat="server" />

and the
Imports MySql.Data.MySqlClient
Imports Ext.Net
Imports System.Xml.Xsl
Imports System.Xml

Public Class _Default
    Inherits System.Web.UI.Page
    Public myconnstr As String = "server=81.***.202.***;" _
                                     & "port=3306;" _
                                     & "uid=***;" _
                                     & "pwd=***;" _
                                     & "database=liviuivil;" _
                                     & "Convert Zero Datetime=True;"
    Public myreader As MySqlDataReader
    Public myconnection As MySqlConnection
    Public mycmd As MySqlCommand
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Store_ReadData(sender As Object, e As StoreReadDataEventArgs)
            Dim store As Store = DirectCast(sender, Store)
            Dim start As Integer = e.Start
            Dim limit As Integer = e.Limit
            Dim coloana As String = e.Sort(0).Property.ToString
            Dim tipsort As String = e.Sort(0).Direction.ToString
            Dim sfilters As String = e.Parameters(gridfilters1.ParamPrefix)
            Dim ffiltru As String = "WHERE "
            If Not String.IsNullOrEmpty(sfilters) Then
                Dim ffc As New FilterConditions(sfilters)
                For Each fcond As FilterCondition In ffc.Conditions
                    Dim fcol As String = fcond.Field
                    Dim ftype As FilterType = fcond.Type
                    If fcond.Type = FilterType.String Then
                        ffiltru = ffiltru + fcol.ToString + "=" + fcond.Value(Of String).ToString + " and "
                    End If
                    If fcond.Type = FilterType.List Then
                        If fcond.List.Count = 1 Then
                            ffiltru = ffiltru + "(" + fcol.ToString + "=" + fcond.List.Item(0).ToString + ")" + " and "
                            ffiltru = ffiltru + "("
                            For i = 0 To fcond.List.Count - 1
                                ffiltru = ffiltru + fcol.ToString + "=" + fcond.List.Item(i).ToString + " or "
                            ffiltru = ffiltru.Substring(0, ffiltru.Length - 4) + ") and "
                        End If
                    End If
            End If
            If ffiltru.Length > 6 Then
                ffiltru = ffiltru.Substring(0, ffiltru.Length - 4)
                ffiltru = ffiltru + "1=1"
            End If
            Dim zzz As String = e.Parameters("cod")
            If Not String.IsNullOrEmpty(zzz) Then
            End If           
            Dim hhh As String = "SELECT line_id,cod,tva FROM local_stoc " + ffiltru + " ORDER BY " + coloana + " " + tipsort + " LIMIT " + start.ToString + "," + limit.ToString
            Label2.Text = hhh
            store.Data = querydbdata("SELECT line_id,cod,tva FROM local_stoc " + ffiltru + " ORDER BY " + coloana + " " + tipsort + " LIMIT " + start.ToString + "," + limit.ToString)
            e.Total = querydb("SELECT COUNT(*) FROM local_stoc " + ffiltru)
        Catch ex As Exception

        End Try
    End Sub

    Protected Sub Store1_Submit(sender As Object, e As StoreSubmitDataEventArgs)
        Dim format As String = Me.FormatType.Value.ToString()
        Dim xml As XmlNode = e.Xml
        Select Case format
            Case "xml"
                Dim strXml As String = xml.OuterXml
                Me.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xml")
                Me.Response.AddHeader("Content-Length", strXml.Length.ToString())
                Me.Response.ContentType = "application/xml"
                Exit Select
            Case "xls"
                Me.Response.ContentType = "application/"
                Me.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xls")
                Dim xtExcel As New XslCompiledTransform()
                xtExcel.Transform(xml, Nothing, Response.OutputStream)
                Exit Select
            Case "csv"
                Me.Response.ContentType = "application/octet-stream"
                Me.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.csv")
                Dim xtCsv As New XslCompiledTransform()
                xtCsv.Transform(xml, Nothing, Response.OutputStream)
                Exit Select
        End Select

    End Sub
    Public Function querydbdata(ByVal xxx As String) As DataTable
        Dim mydatatable As New DataTable
            myconnection = New MySqlConnection(myconnstr)
            Dim myadapter As New MySqlDataAdapter(xxx, myconnection)
        Catch ex As Exception
            ' mydatatable.Columns.Add()
            ' mydatatable.Rows.Add()
            ' mydatatable.Rows(0)(0) = ex.Message.ToString
        End Try
        Return mydatatable
    End Function
    Public Function querydb(ByVal xxx As String) As String
        Dim raspuns As String = ""
            Dim myconnection As New MySqlConnection(myconnstr)
            Dim mycmd As New MySqlCommand(xxx, myconnection)
            raspuns = mycmd.ExecuteScalar()
        Catch ex As Exception
            raspuns = "Eroare : " + ex.ToString
        End Try
        Return raspuns
    End Function
End Class
Tags: VB, VB.NET, ASP.NET, Gridview, search, Ext.Net


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web03-2016 | 2.8.180515.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100