Click here to Skip to main content
15,891,253 members
Articles / Programming Languages / C#

View, View Controller, Model Controller, Model (VVCMCM) Pattern

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
18 Mar 2012CPOL11 min read 18.7K   200   16  
The MVC Pattern was first conceptualized assuming all the three actors were present at one place. Since Web Applications have both a client and a server this needs to be applied differently without technology bias.
var EntityViewController =
{

    //
    ModelControllerName: 'VVCMCM.ModelControllers.Entity',

    Search: function()
    {
        //the this keyword is not working as expected
        //this.ModelControllerName);
        var queryString = '';
        var strShortName = '';
        var strLongName = '';
        var strSKU = '';

        //get the values from the form fields
        strShortName = $('input#txtShortName').val();
        strLongName = $('input#txtLongName').val();
        strSKU = $('input#txtSKU').val();

        //        queryString = Core.CreateQueryString('controller', EntityViewController.ModelControllerName,
        //                                        'action', 'search',
        //                                        'format', 'html',
        //                                        'txtShortName', strShortName,
        //                                        'txtLongName', strLongName,
        //                                        'txtSKU', strSKU
        //                                        );


        queryString = '?method=get' +
                      '&controller=' + EntityViewController.ModelControllerName +
                      '&action=Search' +
                      '&format=xml' +
                      '&' + $("form#searchForm").serialize();

        //enable this for viewing what is being sent
        //alert(queryString);


        var searchUrl = Core.ModelControllerUrl + queryString;

        $.get(searchUrl, function(data)
        {
            EntityViewController.SearchResult(data);
        });

    },

    SearchByPost: function()
    {
        //the this keyword is not working as expected
        //this.ModelControllerName);
        var queryString = '';
        var dataString = '';
        var strShortName = '';
        var strLongName = '';
        var strSKU = '';

        //get the values from the form fields
        strShortName = $('input#txtShortName').val();
        strLongName = $('input#txtLongName').val();
        strSKU = $('input#txtSKU').val();

        queryString = '?method=post' +
                      '&controller=' + EntityViewController.ModelControllerName +
                      '&action=Search';

        dataString = 'format=xml' +
                     '&' + $("form#searchForm").serialize();

        //enable this to understand what is being sent
        //alert(dataString);


        var searchUrl = Core.ModelControllerUrl + queryString;

          $.post(searchUrl, dataString, function(data)
          {
              EntityViewController.SearchResult(data);
          });

    },

    SearchResult: function(data)
    {
        //unload the grid if present
        $("#list1").GridUnload();
        
        $("#list1").jqGrid({
            datastr: data,
            datatype: "xmlstring",
            colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
            colModel: [
   		{ name: 'id', index: 'id', width: 75, sorttype: 'int' },
   		{ name: 'invdate', index: 'invdate', width: 90, sorttype: 'date', datefmt: 'Y-m-d' },
   		{ name: 'name', index: 'name', width: 100 },
   		{ name: 'amount', index: 'amount', width: 80, align: "right", sorttype:'float' },
   		{ name: 'tax', index: 'tax', width: 80, align: "right", sorttype: 'float' },
   		{ name: 'total', index: 'total', width: 80, align: "right", sorttype: 'float' },
   		{ name: 'note', index: 'note', width: 150, sortable: false }
   	],
            rowNum: 10,
            autowidth: true,
            rowList: [10, 20, 30],
            pager: $('#pager1'),
            sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
            caption: "XML Example"
        }).navGrid('#pager1', { edit: false, add: false, del: false });
    }
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Riversand Technologies Inc
India India
Head of Engineering at Riversand Technologies Inc.

Comments and Discussions