Q:

How to get selected item data?

My background is mainly asp.net/c# and I´m new to Durandal/Knockout. I´m trying to build a view to show a list of objects and upon selection of one item, show the selected item´s data. My problem is that whatever item is selected the data returned is always the last item´s data.
Below are my view, 

    ... Markup not shown
<div data-bind="visible: convenios().length > 0" style="height:30px">
Pesquisa retornou <span  data-bind="text: convenios().length"></span> conveniados.
</div>
<div class="row-fluid">
    <section  class="grd-convenio" data-bind="foreach: convenios" style="width:25%; height:300px; overflow-y: scroll">
        <article>
        <div class="grd-convenio-detalhe"  title="Clique para alterar">
            <span class="grd-convenio-nome" data-bind="text: nome"></span>
            <span class="grd-convenio-id" data-bind="text: id"></span><br/>
            <span class="grd-convenio-cidade" data-bind="text: cidade"></span>
            <span class="grd-convenio-ativo" data-bind="text: servicosativos"></span>
        </div>
        </article>        

    </section>
</div>

and part of my viewmodel:
var convenio = function (id, nome, cidade, cnpjcpf, servicosativos) {

    self = this;

    self.idformatado = ko.observable("[" + id + "]");
    self.id = ko.observable(id);
    self.nome = ko.observable(nome);
    self.cidade = ko.observable(cidade);
    self.cnpjcpf = ko.observable(cnpjcpf);
    self.servicosativos = ko.observable(servicosativos);
    self.estiloativo = ko.computed(function () {
        if (self.servicosativos() > 0)
            return 'grd-convenio-detalhe-ativo';
        else
            return 'grd-convenio-detalhe-inativo';
    });
    self.convenioselecionado = ko.observable("");
    return self;

};

var convenios = ko.observableArray([]);
var tamanho = ko.observable("0");
var convenioselecionado = ko.observable("");
var pesquisacodigo = ko.observable("");
var pesquisanome = ko.observable("");
var pesquisacidade = ko.observable("");

var filtrar = function () {

 ... Retrieve data from Database and pushes data into convenios observablearray
            $.each(resultado.pesquisa.retorno, function (i, item) {
                convenios.push(new convenio(item.idconveniado, item.nome, item.cidade, item.cnpjcpf, item.servicosativos));
            });

};

alterarCadastro = function (selecionado) {
    if (selecionado && selecionado.id()) {
        alert(selecionado.nome());
    }
};

var viewAttached = function(view) {
    bindEventToList(view, '.grd-convenio-detalhe', alterarCadastro);
};

var bindEventToList = function (rootSelector, selector, callback, eventName) {
    var eName = eventName || 'click';
    $(rootSelector).on(eName, selector, function () {
        var selecionado = ko.dataFor(this);
        callback(selecionado);
        return false;
    });
};

return {
    convenios: convenios,
    filtrar: filtrar,
    tamanho: tamanho,
    pesquisacodigo: pesquisacodigo,
    pesquisanome: pesquisanome,
    pesquisacidade: pesquisacidade,
    alterarCadastro: alterarCadastro,
    displayName: 'Convênio',
    viewAttached: viewAttached

}

});});
The view is shown as expected but when I select any item the data (ko.datafor) returned in the bindEventTolist function is always the last item´s data. What am I doing wrong? Is this a good approach to this kind of app? TIA.

A:

http://jsfiddle.net/yQgAm/8/
I have updated your fiddle, but it took quite some time : )
You were making it more difficult than it needs to be so I am trying to put some markup on your code to show what I changed, if I can remember it all.  One of the biggest things I went back and did was to rename your methods using camelCase to ensure no typos existed.  Next, I took the parter function out of your viewModel, as it is a class on it's own and doesn't need to be defined in there.
Then I gave your view model a scope with self = this.  This just lets the view model know that anything inside of it with a self. predecessor is defined as part of this scope.
Next, since I am no jsFiddle master and you were trying to use both jQuery ($.each) and KnockOut (ko.) I replaced the $.each with a KnockOut utility called ko.utils.arrayForEach() which basically is the same thing.
I suspect when you were doing a forEach loop with the $.each in your code you were setting the value as the value of selectedPartner and then when you did showSelectedPartner it was just displaying the last value that you had set in your forEach loop.
If you want to take some of your original code and re-use it the biggest thing that I would suggest to do is remove the dependency to so many libraries.  You are confusing yourself by (assumption) learning jQuery, Knockout, and Durandal all at the same time while trying to understand basic JavaScript.  Take it one step at a time or you are going to end up with a LOT of code that does things you aren't 100% sure why.
function partner(id, name) {
    var self = this;
    self.id = ko.observable(id);
    self.pName = ko.observable(name);
}

function viewmodel() {
   var self = this;
   self.initialdata = ko.observableArray([
       { id: 1, name: "name1" } ,
       { id: 2, name: "name2" } ,
       { id: 3, name: "name3" } ,
       { id: 4, name: "name4" } ,
   ]);

    self.partners = ko.observableArray();  
    self.selectedPartner = ko.observable();  

    self.loadData = function () {
        self.partners([]);
        ko.utils.arrayForEach(self.initialdata(), function (item) {
            self.partners.push(new partner(item.id, item.name));
        });
    };
    self.showSelectedPartner = function (selected) {
        alert(selected.pName());
    }
}

ko.applyBindings(new viewmodel());

And your view
<section>
    <div>
        <button data-bind="click: loadData">Load Data</button>
    </div>
    <div data-bind="visible: partners().length > 0" >Query returned <span data-bind="text: partners().length"></span> records</div>
    <div>
        <section data-bind="foreach: partners" >
            <article>
                <div title="Click to Update" data-bind="click: $parent.showSelectedPartner"> <span data-bind="text: id"></span>  
 <span data-bind="text: pName"></span>
                </div>
            </article>
        </section>
    </div>
</section>

I put a click binding on your div because viewAttached is a Durandal method letting the router know that the view is finished attaching and it can do something.  The bindToEventList you created is just saying if anything with that class that you had named it is clicked fire that method.  That is all good to use and more efficient but if you are just learning KnockOut I recommend learning how bindings work first.  

