Results 1 to 3 of 3

Thread: not able to render a window with grid inside

  1. #1

    Default not able to render a window with grid inside

    Hi i cannot seem to render a new window with an grid inside of that.

    ext-all-debug tells me:

    Code:
    c is undefined
    http://localhost/nova/portal/ext-all-debug.js
    Line 34299
    c is undefined
    ext-base.js (lnea 9)
     
    if(typeof c.renderer == "string"){
     
    setConfig()([Object tpl=Object events=Object state=Object, Object header=PId readOnly=true dataIndex=pid width=40, Object header=Contact name dataIndex=contactname width=200, 6 more... 0=Object 1=Object 2=Object 4=Object 5=Object 6=Object], true)ext-all-debug.js (lnea 34299)
    ColumnModel()([Object tpl=Object events=Object state=Object, Object header=PId readOnly=true dataIndex=pid width=40, Object header=Contact name dataIndex=contactname width=200, 6 more... 0=Object 1=Object 2=Object 4=Object 5=Object 6=Object])ext-all-debug.js (lnea 34243)
    SupplierContacts()("33")supplier...ntacts.js (lnea 111)
    handler()()providers-grid.js (lnea 481)
    onClick()(Object browserEvent=Event blur button=-1 type=blur)ext-all-debug.js (lnea 20504)
    h()()ext-all-debug.js (lnea 1723)
    apply()()ext-base.js (lnea 9)
     
     
    if(typeof c.renderer == "string"){

    the code where i call the function is :

    Code:
     
    tbar
    
    :[{ // Lets add some buttons to the top bar of suppliers grid
    // add contact
    text
    :'Contact Management', iconCls
    :'suppliers-add-contact',//create icon handler
    :function(){ // we have to get the click on the supplier
    var st = Ext.getCmp('providers_grid'); //alert(st); var tester = st.getSelectionModel(); //alert(tester); var m=tester.getSelections(); // alert(m); //var record = PROVIDERS_store.getAt(m[0]); // alert(m[0].get('PROVID')); if(m[0]!=null){
    var Contprov =new Ext.Window({
    layout
    :'card', // region:'center',
    id
    :'ContactsWindow', closable
    :true, resizable
    :true, //modal: true,
    border
    :true, plain
    :true, closeAction
    :'hide', title
    :'Contact Management', width
    :440, height
    :320, //deferredRender: true ,
    //renderTo: 'portal', //renderTo: Ext.getBody(),
    /*
    111. * Aprovechamos para ver otro tipo de asignacin de items, 112. * en vez de definirlos en el bloque 'items' lo asignamos 113. * desde una variable 114. */ items
    :[SupplierContacts(m[0].get('PROVID'))] // here call it });
    Contprov
    .show(); }
    else{ Ext
    .MessageBox.alert('Message','please... Click a row to open contact management for this supplier!'); }
    }
    },
    and the function that will not render
    Code:
    /**
    *@authortwinners */
    SupplierContacts = function(providerID) { var expander = new Ext.grid.RowExpander({ //compenen dari expander row tpl : new Ext.Template( ////below is a field that will expand '<p><b>Contact Name:</b> {contactname}</p><br>' , '<p><b>Contact Email:</b> {contactemail}</p><br>' , '<p><b>Contact Phone:</b> {contactphone}</p><br>' , '<p><b>Contact Skype:</b> {skype}</p><br>' , '<p><b>Contact Additonal:</b> {additional}</p><br>' , '<p><b>Added:</b> {added}</p><br>' ) }); function iconactive(value) { if (value == 1) return '<img src="icons/accept.png" border="0" >'; elsereturn '<img src="icons/delete.png" border="0">'; } var SimpleDataStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ url : 'supplier_contacts.php?pid=' + providerID, method : 'POST' }), reader : new Ext.data.JsonReader({ root : 'results', totalProperty : 'total' }, [{ name : 'pid', type : 'int' }, { name : 'contactname', type : 'string' }, { name : 'contactemail', type : 'string' }, { name : 'contactphone', type : 'string' }, { name : 'skype', type : 'string' }, { name : 'additional', type : 'string' }, { name : 'added', type : 'string' }, { name : 'cid', type : 'int' }]), sortInfo : { field : 'contactname', direction : "ASC" } }); SimpleDataStore .load({ params : { start : 0, limit : 10 } }); var SimpleColumnModel = new Ext.grid.ColumnModel([expander, { header : 'PId', readOnly : true, dataIndex : 'pid', width : 40, hidden : false }, { header : 'Contact name', dataIndex : 'contactname', width : 200 }, , { header : 'Email', dataIndex : 'contactemail', width : 200 }, { header : 'Phone', dataIndex : 'contactphone', width : 100 }, { header : 'Skype', dataIndex : 'skype', width : 200 }, { header : 'Additional', dataIndex : 'additional', width : 200 }, { header : 'Added on', dataIndex : 'added', width : 100 }]); SimpleColumnModel .defaultSortable = true; //<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>// //additional tutorial today... create form edit var formEdit = new Ext.form.FormPanel({ url : 'supplier_contacts.php?act=edit', baseCls : 'x-plain', labelWidth : 90, defaultType : 'textfield', reader : new Ext.data.JsonReader({ root : 'results', totalProperty : 'total', id : 'pid', fields : ['pid', 'contactname', 'contactemail', 'contactphone', 'skype', 'additional', 'added'] }), items : [new Ext.form.Hidden({ name : 'pid' }), { fieldLabel : 'ContactName', name : 'contactphone', anchor : '100%' }, { fieldLabel : 'Email', name : 'contactemail', anchor : '100%' }, { fieldLabel : 'Phone', name : 'contactphone', anchor : '100%' }, { fieldLabel : 'Skype', name : 'skype', anchor : '100%' }, { xtype : 'textarea', fieldLabel : 'Additonal', name : 'contactphone', anchor : '100%' }], buttons : [{ text : 'SAVE', handler : function() { formEdit .getForm().submit({ waitMsg : 'Storing Contact...', failure : function(form, action) { Ext .MessageBox.alert('Error Message', 'Data Failure.....'); formEdit .getForm().reset(); }, success : function(form, action) { Ext .MessageBox.alert('Confirm', 'Success storing contact...'); SimpleDataStore .load({ params : { start : 0, limit : 10 } }); window .hide(); formEdit .getForm().reset(); } }) } }, { text : 'Cancel', handler : function() { window .hide(); } }] }); var simpleAdd = new Ext.FormPanel({ url : 'supplier_contacts.php?act=add', xtype : 'panel', // title: 'Add family', layout : 'form', //frame: true, labelWidth : 95, defaults : { allowBlank : false }, items : [new Ext.form.Hidden({ name : 'cid', value : providerID }), { xtype: 'miscfield', id : 'miscfield_novalue', width : '90%', value : '<b>Adding Contact</b>' }, { fieldLabel : 'ContactName', name : 'contactphone', anchor : '100%' }, { fieldLabel : 'Email', name : 'contactemail', anchor : '100%' }, { fieldLabel : 'Phone', name : 'contactphone', anchor : '100%' }, { fieldLabel : 'Skype', name : 'skype', anchor : '100%' }, { xtype : 'textarea', fieldLabel : 'Additonal', name : 'contactphone', anchor : '100%' }], buttons : [{ text : 'Save', handler : function() { if (simpleAdd.getForm().isValid()) { simpleAdd .getForm().submit({ waitMsg : 'Storing contact...', success : function(simpleAdd, o) { Ext .MessageBox.alert('Creation OK', 'Contact stored with Success..'); SimpleDataStore .reload(); SimpleWindow .hide(); }, failure : function(simpleAdd, o) { Ext .MessageBox.alert('Warning', 'Storing Contact Failure...'); } }); } } }, { text : 'Reset', handler : function() { simpleAdd .getForm().reset(); } }] }); var SimpleWindow = new Ext.Window({ title : 'Add a contact for supplier', closable : true, closeAction : 'hide', width : 340, height : 160, layout : 'fit', modal : true, items : simpleAdd }); function displayFormWindow() { if (!SimpleWindow.isVisible()) { SimpleWindow .show(); } else { SimpleWindow .toFront(); } } var window = new Ext.Window({ title : 'Edit Contact', width : 340, height : 300, minWidth : 300, minHeight : 300, layout : 'card', plain : true, bodyStyle : 'padding:3px;', buttonAlign : 'center', closeAction : 'hide', modal : true, animCollapse : true, activeItem : 0, items : [formEdit] }); //function delete function del(btn) { if (btn == 'yes') { var m = Ext.getCmp('longshots').getSelectionModel().getSelectedCell(); var record = SimpleDataStore.getAt(m[0]); // ext request Ext .Ajax.request({ url : 'supplier_contacts.php', success : function() { Ext.Msg.alert('Status', 'Contact deleted sucessfully!', function(btn, text) { if (btn == 'ok') { //Ext.getCmp('providersPanel').findById('tab-panel').setActiveTab(1); //Ext.getCmp('providersPanel').PROVIDERS_store.reload({params:{start: 0, limit: 4}}); SimpleDataStore .reload({ params : { start : 0, limit : 6 } }); } }); }, failure : function(action) { if (action.failureType == 'server') { obj = Ext.util.JSON.decode(action.response.responseText); Ext.Msg.alert('Deleting contact has Failed!', obj.errors.reason); } else { Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText); } //saveSuppliers.getForm().reset(); }, waitTitle : 'Connecting', waitMsg: 'Sending data...', headers : { 'my-header': 'foo' }, params : { del: record.get("pid") } }); //SimpleDataStore.on('load',{ //SimpleDataStore.reload(); //}); } } SupplierContacts .superclass.constructor.call(this, { title : 'Family of suppliers', id : 'longshots', store : SimpleDataStore, cm : SimpleColumnModel, loadMask : true, //componen tbar tbar : [{ //button edit text : 'Edit', iconCls : 'edit-grid', //create icon handler : function() { // s var m = Ext.getCmp('longshots').getSelectionModel().getSelectedCell(); //alert(s); //alert(record.get('family_id')); //alert(s.getSelected().get('family_id')); //return; //var m = Ext.getCmp('longshot').getSelectionModel().getSelections();//function select if (m != null) { var record = SimpleDataStore.getAt(m[0]); //get id formEdit .getForm().load({ url : 'supplier_contacts.php?act=get&cid=' + record.get('cid') + '&pid=' + record.get('pid'), waitMsg : 'Loading' }); window .show(); } else { Ext .MessageBox.alert('Message', 'please... Click a row to edit a contact!'); } } }, { //buttton delete text : 'Delete', iconCls : 'delete', //create icon handler : function() { var m = Ext.getCmp('longshot').getSelectionModel().getSelectedCell(); if (m != null) { Ext .MessageBox.confirm('Message', 'are you sure to delete this contact?', del); } else { Ext .MessageBox.alert('Message', 'please... Click a row to delete a contact...!'); } } }, '-', { text : 'Add', iconCls : 'add', handler : displayFormWindow }], viewConfig : { forceFit : true }, plugins : expander, frame : true, collapsible : true, animCollapse : true, width : 480, height : 350, bbar : new Ext.PagingToolbar({ pageSize : 6, store : SimpleDataStore, displayInfo : true, displayMsg : 'Displaying data {0} - {1} of {2}', emptyMsg : "No data to display" }) }); //SimpleListingEditorGrid.show(); // SimpleListingEditorGrid.render('form'); } Ext .extend(SupplierContacts, Ext.grid.EditorGridPanel);

  2. #2
    Sencha User BitPoet's Avatar
    Join Date
    Sep 2008
    Location
    Bavaria
    Posts
    277

    Default

    Hi phpfreak,

    you should consider formatting your code more readable, the snippets above with their intermittent line wraps and missing indentation make it a pain to read through it. If it's just your editor losing formatting when copy&pasting, you can always go to jsbeautifier.org and have it re-formatted autmoatically (make sure to uncheck 'Preserve line breaks').

  3. #3

    Default hi

    Hi ,

    I just ran it through beautifier but when pasting it comes up the same.
    Not sure what or how .

    Thanks for the heads up anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •