1. #1
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    19
    Vote Rating
    0
    pym is on a distinguished road

      0  

    Default TimeField in grid with both editor and custom render

    TimeField in grid with both editor and custom render


    I'm using a time field for start/end times.

    initially I was using renderer: Ext.util.Format.dateRenderer('H:i') which displayed the time as
    I wanted - but any edits caused a NaN. Following the existing forum posts I swiched to
    a custom renderer which did nothing (except I'm guessing cast from string to date) and it did
    make the editing functional - however the display when not editing is now the full date string.

    var timeEditor = new fm.TimeField({format:'H:i', minValue: '0:01 AM', maxValue: '4:00 AM', increment: 1});
    function renderTime(value){
    return value;
    };

    {header: 'Start',width: 180,dataIndex: 'start_time', editor: timeEditor, renderer: renderTime},
    {header: 'End',width: 180,dataIndex: 'end_time',editor: timeEditor, renderer: renderTime},

    I've seen (and tried) various renderTime workaround examples like if value.length== 5 then value.format.. which do not work for showing a formatted time.

    Does anyone have method of rendering a timefield in a grid which allows formatting the time and editing?

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    19
    Vote Rating
    0
    pym is on a distinguished road

      0  

    Default


    I have found a functional answer allowing editing and formatting the time field without getting an nan... or at least not keeping it.
    In the actual update function I can convert the time-string back to a date as follows then set the records value to the date.
    It does flash NAN for a second - but it works. I think that if the time field could on edit return a datetime value instead of a time string this could be avoided - is it possible to have the time editor use the raw date value instead of the render/formatted string of time.
    if ((e.field == 'start_time') || (e.field == 'end_time')) {
    var d = new Date('Jan 1, 1970 ' + e.value);
    e.record.set(e.field,d);
    }

  3. #3
    Ext JS Premium Member
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    139
    Vote Rating
    1
    Spirit is on a distinguished road

      0  

    Default


    Hi Prym!

    Seems we had the same problem:
    Here is a renderer, which worked for me:
    http://www.sencha.com/forum/showthre...-H-i-Roweditor

    Regards
    Spirit

  4. #4
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    64
    Vote Rating
    4
    team.avesta is on a distinguished road

      0  

    Default


    Anybody find any solution for this problem...???
    .
    Please share it on forum.

Similar Threads

  1. timefield grid editor rejects value
    By 448191 in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 6 Apr 2010, 1:30 AM
  2. Editor Grid Timefield
    By ssawant in forum Ext 2.x: Help & Discussion
    Replies: 13
    Last Post: 3 Mar 2009, 5:09 AM
  3. Editor / Property Grid throws errors after using custom editor
    By para in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 15 Jun 2007, 9:19 AM
  4. Custom editor in the grid.
    By vatech1993 in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 28 Nov 2006, 5:18 AM

Thread Participants: 2