Page 4 of 9 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 83

Thread: problem

  1. #31

    Default problem

    Thanks for ur reply

    i modified a js code as ur guidence but still not working
    My js code

    help me .....

    PHP Code:
     
     
    /*
     * Ext JS Library 2.1
     * Copyright(c) 2006-2008, Ext JS, LLC.
     * [email protected]
     * 
     * http://extjs.com/license
     */
    Ext.onReady(function(){
        
    Ext.QuickTips.init();
        
    // turn on validation errors beside the field globally
        
    Ext.form.Field.prototype.msgTarget 'side';
        var 
    bd Ext.getBody();
    //   Define the Grid data and create the Grid
        
    var myData = [
            [
    '3m Co',71.72,0.02,0.03,'9/1 12:00am','details.gif'],
            [
    'Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am','topic.gif']
            
        ];
        var 
    ds = new Ext.data.Store({
            
    reader: new Ext.data.ArrayReader({}, [
                   {
    name'company'},
                   {
    name'price'type'float'},
                   {
    name'change'type'float'},
                   {
    name'pctChange'type'float'},
                   {
    name'lastChange'type'date'dateFormat'n/j h:ia'},
          {
    name'renderNPreview'}
              ])
        });
        
    ds.loadData(myData);
        
    // example of custom renderer function
        
    function italic(value){
            return 
    '<i>' value '</i>';
        }
        
    // example of custom renderer function
        
    function change(val){
            if(
    val 0){
                return 
    '<span style="color:green;">' val '</span>';
            }else if(
    val 0){
                return 
    '<span style="color:red;">' val '</span>';
            }
            return 
    val;
        }
        
    // example of custom renderer function
        
    function pctChange(val){
            if(
    val 0){
                return 
    '<span style="color:green;">' val '%</span>';
            }else if(
    val 0){
                return 
    '<span style="color:red;">' val '%</span>';
            }
            return 
    val;
        }
    function 
    renderNPreview(value){
    return  
    '<img  src="'+value+'">';
    }
        
    // the DefaultColumnModel expects this blob to define columns. It can be extended to provide
        // custom or reusable ColumnModels
        
    var colModel = new Ext.grid.ColumnModel([
            {
    id:'company',header"Company"width160sortabletruelocked:falsedataIndex'company'},
            {
    header"Price"width75sortabletruerendererExt.util.Format.usMoneydataIndex'price'},
            {
    header"Change"width75sortabletruerendererchangedataIndex'change'},
            {
    header"% Change"width75sortabletruerendererpctChangedataIndex'pctChange'},
            {
    header"Last Updated"width85sortabletruerendererExt.util.Format.dateRenderer('m/d/Y'), dataIndex'lastChange'},
      {
    id:'renderNPreview',header"renderNPreview"width75sortabletruerendererrenderNPreviewdataIndex'renderNPreview'}
        ]);
        
    bd.createChild({tag'h2'html'Using a Grid with a Form'});
    /*
     * Here is where we create the Form
     */
        
    var gridForm = new Ext.FormPanel({
            
    id'company-form',
            
    frametrue,
            
    labelAlign'left',
            
    title'Company data',
            
    bodyStyle:'padding:5px',
            
    width750,
            
    layout'column'// Specifies that the items will now be arranged in columns
            
    items: [{
                
    columnWidth0.6,
                
    layout'fit',
                
    items: {
                 
    xtype'grid',
                 
    dsds,
                 
    cmcolModel,
                 
    sm: new Ext.grid.RowSelectionModel({
                     
    singleSelecttrue,
                     
    listeners: {
                         
    rowselect: function(smrowrec) {
                             
    Ext.getCmp("company-form").getForm().loadRecord(rec);
           
    //var myGrid = Ext.getCmp('renderNPreview');
                                // myGrid.sm.getSelections();
                         
    }
                     }
                 }),
         
                 
    autoExpandColumn'company',
                 
    height350,
                 
    title:'Company Data',
                 
    bordertrue,
              
    listeners: {
               
    render: function(g) {
                
    g.getSelectionModel().selectRow(0);
               },
               
    delay10 // Allow rows to be rendered.
              
    }
             }
            },{
             
    columnWidth0.4,
                
    xtype'fieldset',
                
    labelWidth90,
                
    title:'Company details',
                
    defaults: {width140}, // Default config options for child items
                
    defaultType'textfield',
                
    autoHeighttrue,
                
    bodyStyleExt.isIE 'padding:0 0 5px 15px;' 'padding:10px 15px;',
                
    borderfalse,
                
    style: {
                    
    "margin-left""10px"// when you add custom margin in IE 6...
                    
    "margin-right"Ext.isIE6 ? (Ext.isStrict "-10px" "-13px") : "0"  // you have to adjust for it somewhere else
                
    },
                
    items: [{
                    
    fieldLabel'Name',
                    
    name'company'
                
    },{
                    
    fieldLabel'Price',
                    
    name'price'
                
    },{
                    
    fieldLabel'% Change',
                    
    name'pctChange'
                
    },{
                    
    xtype'datefield',
                    
    fieldLabel'Last Updated',
                    
    name'lastChange'
                
    },
        {
                   
    // xtype: 'datefield',
                   
    xtype'box',
                 
    id  'renderNPreview',
        
    autoEl: {tag'img'src:''}
                  
                      
                }]
            }],
            
    renderTobd
        
    });
        
       
       
    }); 

  2. #32

    Default

    dude.... what is the problem? u got an error? have you check the listener rowselect?
    try to add console.log(..) (if using firebug)
    try to add breakpoints in that listeners...
    check all the parameter inside that function ( sm, row, rec )..
    explore all the parameter... how you can get data that suits your need....

    and i think the first post i made... can give you more clear clue....

    keep trying bro...

  3. #33

    Default problem

    Thanks for ur reply

    u run my js code its show 4 column last colum is image as test.gif,details.gif ...grid view all records no problem

    only problem on selection row if u select the row the textfields are show but not images

    plz solve it i spend . 2 days for this still no result
    help me


    Thanks in advance

  4. #34

    Default

    well actualy... i have tried and resolved your problem...

    but as animal said... if i just give you the code, when will you learn it... the harder you tried then you'll get more thing to understand...

    have you check the rowselect that attached to grid?

    PHP Code:
                     listeners: {
                         
    rowselect: function(smrowrec) {
                             
    Ext.getCmp("company-form").getForm().loadRecord(rec);
           
    //var myGrid = Ext.getCmp('renderNPreview');
                                // myGrid.sm.getSelections();
                             
                                // explore sm, row, and rec
                                // do smth that i've told you...
                                // Ext.getCmp(...).el.dom.src = [your image path that you can get it from the data]
                         
    }
                     } 
    one common question.. are you using firebugs?

  5. #35
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Rudy has almost handed you the key.

    Take that code, and step through it in Firebug.

    Use firebug to poke into sm, row, rec.

    The API documentation does tell you what they are, but you can also explore them in detail yourself.

  6. #36

    Default problem

    Thanks for ur reply

    i modify js code as ur guidence

    but still problem
    PHP Code:
    listeners: {
                         
    rowselect: function(smrowrec) {
                             
    Ext.getCmp("company-form").getForm().loadRecord(rec);
                                 
                                
    Ext.getCmp(''renderNPreview").el.com.src = renderNPreview;                     }
                     } 

    .......
     
    {
                   // xtype: 'datefield',
                   xtype: 'box',
                 id  : 'renderNPreview',
        autoEl: {tag: 'img', src:''}
                  
                      
                } 
    Error: Ext.getCmp(''renderNPreview").el.com.src has no properties

  7. #37
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Right. That's because you are not givnig the img that ID like I told you.

  8. #38

    Default problem

    u mean

    here

    autoEl: { id:renderNPreview, tag: 'img', src:''}

  9. #39
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    So what does the variable renderNPreview contain when that code is run?

  10. #40

    Default problem

    its call function

    PHP Code:
    function renderNPreview(value){
    return  
    '<img  src="'+value+'">';


Page 4 of 9 FirstFirst ... 23456 ... LastLast

Posting Permissions

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