Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
get data from tabel and send to view
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Gert V  
View profile  
 More options Mar 13, 11:42 am
From: Gert V <gert.verstrae...@gmail.com>
Date: Wed, 13 Mar 2013 08:42:30 -0700 (PDT)
Local: Wed, Mar 13 2013 11:42 am
Subject: get data from tabel and send to view

We use pyramid and chameleon template.

Currently we have a page where users can fill in a table.
This table has a variable lenght because rows are added dynamically.
We want to get all the content of the table and put it in a list, so we
send it to our database.

The biggest problem is that we don't know how to send the data to a list
and get it to our vieuw.
can some1 help me with this problem?
thanks in advance.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincent Catalano  
View profile  
 More options Mar 13, 12:28 pm
From: Vincent Catalano <vinc...@vincentcatalano.com>
Date: Wed, 13 Mar 2013 09:28:29 -0700
Local: Wed, Mar 13 2013 12:28 pm
Subject: Re: get data from tabel and send to view

Can you be a bit more specific with what you are attempting to do? Have you
created a form with input fields throughout this table? Are you posting the
form data to your pyramid application?

-Vincent

--
Vincent Catalano
Software Engineer and Web Ninja,
(520).603.8944

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gert V  
View profile  
 More options Mar 13, 2:43 pm
From: Gert V <gert.verstrae...@gmail.com>
Date: Wed, 13 Mar 2013 11:43:45 -0700 (PDT)
Local: Wed, Mar 13 2013 2:43 pm
Subject: Re: get data from tabel and send to view

Thanks for the fast reply. sorry i wasn't clearer on my previous post. If
annything is still not documentated enough please let me know.
i'll give some code snippets of my template. no data is loaded into this
page. the user has to fill in a few fields and after that we want to store
it to our database.

<div id="diagnoses_zelf" class="span5 well">
            <form >    
            <h5>Diagnoses</h5>
                <table id="tableDiagnose" class="table table-hover">
                        <thead class="header">
                            <tr>
                                <th>Nr.</th>
                                <th>Code</th>
                                <th>Uitleg</th>
                                <th>Zek</th>
                                <th>Aan</th>
                            </tr>
                        </thead>
                        <tr>
                            <td>A</td>
                            <td><input type='text' id="dz_code"
class="input-mini" onFocus="isleegveld(this.value)"
onchange="voegrijtoe_Diagnose(this.value)" placeholder="Code"></input></td>
                            <td style="max-width: 140px; word-wrap:
break-word">some random text</td>
                            <td><input type='text' id="dz_zek"
class="input-mini1" ></input></td>
                            <td><input type='text' id="dz_aan"
class="input-mini1" ></input></td>
                        </tr>                        
                    </table>
            </form>
        </div>        

every time the user has filled in the dz_code textfield, annother textfield
will appear beneeth it. (using javascript)
I'd like to get all the data of this table into a list. each row is a
medical file of a patient and should be placed in a table "medical files".
To bring it to our database I understood I need to bring this list to a
view in our views.py so we can send it to the database.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincent Catalano  
View profile  
 More options Mar 13, 5:57 pm
From: Vincent Catalano <vinc...@vincentcatalano.com>
Date: Wed, 13 Mar 2013 14:57:18 -0700
Local: Wed, Mar 13 2013 5:57 pm
Subject: Re: get data from tabel and send to view

I would recommend spending some more time reading the Pyramid
documentation, especially how Pyramid handles form posts with View
Callables:
http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/vie...
.

-Vincent

--
Vincent Catalano
Software Engineer and Web Ninja,
(520).603.8944

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cropr  
View profile  
 More options Mar 14, 4:07 am
From: cropr <ruben.dec...@gmail.com>
Date: Thu, 14 Mar 2013 01:07:22 -0700 (PDT)
Local: Thurs, Mar 14 2013 4:07 am
Subject: Re: get data from tabel and send to view

Gert,

What you could do is the following.  Make on the client in javascript a
datastructure (probably a list), that has all the relevant data from the
table.   Do a JSON.stringify() on a the data structure and send the
resulting string to the webserver either using a hidden field in a form,
either using an AJAX call.  On the webserver it is very easy to decode the
string back to the datastructure:  in PHP use json_decode, in Node.js use
JOSN.parse, in Python use json.loads ...

Ruben Decrop


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xinfa tang  
View profile  
 More options Mar 14, 11:54 pm
From: xinfa tang <tangxi...@gmail.com>
Date: Thu, 14 Mar 2013 20:54:54 -0700 (PDT)
Local: Thurs, Mar 14 2013 11:54 pm
Subject: Re: get data from tabel and send to view

You can submit a form with multiple records(this's how checkbox works),
because you data is come from a html table, not in input control, you need
collect all your data in json(take a loook at jquery.ajax) and build a form
submit you wanted, the pyramid side will decode the form submit normally,
and you can access them in request.POST(remember it's a multidict, can hold
multiple values per key).

在 2013年3月14日星期四UTC+8上午2时43分45秒,Gert V写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gert V  
View profile  
 More options Mar 15, 10:03 am
From: Gert V <gert.verstrae...@gmail.com>
Date: Fri, 15 Mar 2013 07:03:23 -0700 (PDT)
Local: Fri, Mar 15 2013 10:03 am
Subject: Re: get data from tabel and send to view

Thx for all previous reactions.
We got all our tabledata into a json. It looks like this:

    function neeminhoud()
    {
        var headers = [];
        var InputsArray = [];
        var Data = [];

        var oTable = document.getElementById('tableDiagnose');
        var rijen = oTable.rows.length;
        //gets table
        //loops through rows
           var oCells = oTable.rows.item(0).cells;
           //gets cells of current row
           var cellLength = oCells.length;
               for(var j = 0; j < cellLength; j++)
               {
                   //loops through each cell in current row
                      <!--get your cell info here-->
                      //var cellVal = oCells.children[j].value;
                    if(j != 2)
                    {
                        if(j > 2)
                        {
                            headers[j] =oCells.item(j).innerHTML;
                            var cellVal = oCells.item(j).innerHTML;
                            //alert(cellVal);
                        }
                        else
                        {
                            headers[j-1] =oCells.item(j).innerHTML;
                            var cellVal = oCells.item(j).innerHTML;
                            //alert(cellVal);
                        }
                    }  
               }
               for (i = 1; i < rijen; i++)
               {              
                    var inputs =
oTable.rows.item(i).getElementsByTagName("input");
                    var inputslengte = inputs.length;
                    var rijData = {};
                    for(var j = 0; j < inputslengte; j++)
                    {
                        //alert(inputs.length);
                        var inputval = inputs[j].value;
                        rijData[headers[j]] = inputval;

                        alert(inputval);
                    }
                    Data.push(rijData);
                    alert(Data);
               }
    }

Now we'd like to send it to our view using AJAX so we can send it to our
model/database.
How can we do this, cause we can't seem to find the documentation for this.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gert V  
View profile  
 More options Mar 16, 12:09 pm
From: Gert V <gert.verstrae...@gmail.com>
Date: Sat, 16 Mar 2013 09:09:34 -0700 (PDT)
Local: Sat, Mar 16 2013 12:09 pm
Subject: Re: get data from tabel and send to view

We managed to set up a ajax request with our data inside.
We get the succes message, but we don't know how to get the json out of our
ajax request.

We added these lines in our views.py

def get_items(request):
    return {request}  

@view_config(route_name='
diagnose', xhr=True, renderer='json')
def r_ajax(request):
    items = get_items(request)
    logger = logging.getLogger("random")
    logger.warning(json.dumps(items))

our ajax post looks like this:
                  $.ajax({
                      type: "POST",
                      url: "/diagnose",
                      dataType: "json",
                      data: Data,
                      success: function (msg) {
                        alert("succes: " + msg);
                      },
                      error: function(){
                          alert(msg + 'tet');
                          }                      
                   });

how can we get the json out of our ajax request?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malthe Borch  
View profile  
 More options Mar 16, 4:12 pm
From: Malthe Borch <mbo...@gmail.com>
Date: Sat, 16 Mar 2013 21:12:45 +0100
Local: Sat, Mar 16 2013 4:12 pm
Subject: Re: get data from tabel and send to view
This is related to jQuery, not the Python framework that you're using.

Note that the `success` function receives more arguments than just the message.

\malthe

On 16 March 2013 17:09, Gert V <gert.verstrae...@gmail.com> wrote:

--
Au revoir, et tous mes voeux pour un avenir plein de succès et de bonheur ––

Malthe Borch
mbo...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »