hi Guys...i have two jquery functions.first one is showing data in grid and we can also update data in grid..
2nd one is filtering data like if we want to see data of 'farhad' so it will bring data according to 'farhad';
i want to merge both functions in one platform like i want to update data in grid and also want to filter data on same grid...

first function code is....

<script type="text/javascript">
        $(document).ready(function () {
            // prepare the data
            var data = {};
            var theme = 'classic';

            var source =
            {
                 datatype: "json",
                 datafields: [
                     { name: 'name'},
                     { name: 'id'}
                ],
                id: 'id',
                url: 'data_qualification.php',          
                updaterow: function (rowid, rowdata, commit) {
                    // synchronize with the server - send update command
                    var data = "update=true&name=" + rowdata.name;// + "&LastName=" + rowdata.LastName + "&Title=" + rowdata.Title;
///                 data = data + "&Address=" + rowdata.Address + "&City=" + rowdata.City  + "&Country=" + rowdata.Country + "&Notes=''";
                    data = data + "&id=" + rowdata.id;

                    $.ajax({
                        dataType: 'json',
                        url: 'data_qualification.php',
                        data: data,
                        success: function (data, status, xhr) {
                            // update command is executed.
                            commit(true);
                        }
                    });     
                }
            };

            var dataAdapter = new $.jqx.dataAdapter(source);

            // initialize jqxGrid
            $("#jqxgrid").jqxGrid(
            {
                width: 280,
                height: 350,
                selectionmode: 'singlecell',
                source: dataAdapter,
                theme: theme,
                editable: true,
                columns: [
                      { text: 'ID', editable: false, datafield: 'id', width: 100 },

                      { text: ' Certificate Name', datafield: 'name', width: 180 }

                  ]
            });
        });
    </script>

2nd function is

script type="text/javascript">
        $(document).ready(function () {
            // prepare the data
            var theme = 'classic';

            var source =
            {
                 datatype: "json",
                 datafields: [
                     { name: 'ShippedDate', type: 'date'},
                     { name: 'ShipName'},
                     { name: 'ShipAddress'},
                     { name: 'ShipCity'},
                     { name: 'ShipCountry'}
                ],
                url: 'data.php',
                filter: function()
                {
                    // update the grid and send a request to the server.
                    $("#jqxgrid").jqxGrid('updatebounddata');
                }
            };      

            // initialize jqxGrid
            $("#jqxgrid").jqxGrid(
            {       
              width : 900,
                source: source,
                theme: theme,
                filterable: true,
                columns: [
                      { text: 'Shipped Date', datafield: 'ShippedDate', cellsformat: 'yyyy-MM-dd', width: 200 },
                      { text: 'Ship Name', datafield: 'ShipName', width: 200 },
                      { text: 'Address', datafield: 'ShipAddress', width: 180 },
                      { text: 'City', datafield: 'ShipCity', width: 100 },
                      { text: 'Country', datafield: 'ShipCountry', width: 140 }
                  ]
            });
        });
    </script>

waiting for solution
Regards..
Farhad Idrees

Recommended Answers

All 5 Replies

Well that depends entirely on what you mean by "merge".

i want to use both functions 1-update grid 2-filtering data...
on one grid...

Yes, I understand that but "merge" is still open to interpretation. What is the scenario?

scenario is that...
i want want to use both functions in one datagrid.....
how can i tell u anymore? for example i want to show data in grid, update data from datagrid, filter data using same datagrid...

Some questions to help you :

  • What is the current behaviour?
  • What is the required behaviour?
  • Why are there two separate scripts, each with its own $(document).ready(function() {...}) structure?
  • Do you want to combine the two scripts into one by editing the source?
  • Do you want to keep the two scripts as they are and somehow have some as yet unwritten piece of code combine their functionality?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.