customizing out of the box webpart
-
terça-feira, 21 de agosto de 2012 03:22
Hi,
I need to populate a HTML form webpart with a dropdown that consists of a unique list of values from a sharePoint list column. My source SharePoint list is an external list. so I am only left with Javascript Client object model. How can I do this? Can anyone please help?
Thanks
Todas as Respostas
-
terça-feira, 21 de agosto de 2012 06:55
Hi
Did you consider using InfoPath?
Also you can create webpart using Visual Studio 2010 and there prepopulate all fields from external list. I would focus on asp.net form rather than HTML.
Regards, Marcin (Please mark as helpful or answered if it helps)
-
terça-feira, 21 de agosto de 2012 12:44
I need to connect HTML form web part to other webparts on the page.
-
terça-feira, 21 de agosto de 2012 14:02
You can use
<script type="text/javascript" src="filelink/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.5.4.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Announcements",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
});
</script>
<ul id="tasksUL"/>
Sharepoint Dummy
- Sugerido como Resposta SharepointDummy quarta-feira, 22 de agosto de 2012 08:44
- Não Sugerido como Resposta Hemendra AgrawalMicrosoft Community Contributor, Moderator segunda-feira, 31 de dezembro de 2012 09:19
-
terça-feira, 21 de agosto de 2012 22:43
How do I make this to work with Sharepoint HTML form webpart?
-
quarta-feira, 22 de agosto de 2012 08:44
Add a HTML form webpart on your page.
Open Sharepoint designer and create an external content type. Connect to the external table (Let me know if you need help doing this). Now create an external list and select this external content type.
Now use the above code and replace with your listName and FieldRef Name. You will get the list populated using the javascript, moreover if you need unique values, make sure your list has the FieldRef Name, defined as unique at list level.
Sharepoint Dummy
- Sugerido como Resposta SharepointDummy quarta-feira, 22 de agosto de 2012 08:44
- Não Sugerido como Resposta rythm20 quinta-feira, 23 de agosto de 2012 05:52
-
quinta-feira, 23 de agosto de 2012 05:52
I have a HTML form webpart that is customized so that it has a dropdown with list of values dynamically generated from a SharePoint list using Javascript client object model. I have the HTML form webpart dropdown populating correctly. I was also set up webpart connection to another webpart on the same page. However, when a user selects a value and clicks 'Go' button on the form webpart, the data is not being passed to the consumer webpart. any ideas what is going on? or what am i doing wrong...? it looks like it is always sending a blank value to the consumer webpart.
Below is the script I am using:
<script type="text/javascript" language="javascript">
ExecuteOrDelayUntilScriptLoaded(GetMyList, "sp.js");
var myItems;
function GetMyList() {
var Context = new SP.ClientContext.get_current();
var currentWeb = Context.get_web();
var myList = currentWeb.get_lists().getByTitle('MyList');
var myQuery = new SP.CamlQuery;
myQuery.ViewXml = "<View ><Method Name='Read List'/><Query/></View>";
myItems = myList.getItems(myQuery);
Context.load(myItems, 'Include(myField)');
Context.executeQueryAsync(Function.createDelegate(this, requestSuccess), Function.createDelegate(this, requestFail));
}
function requestFail(sender, args) {
alert('requestSuccess() failed:' + args.get_message());
}
function requestSuccess(sender, args)
{
var myEnumerator = myItems.getEnumerator();
var myDropDown = getMyitems(myEnumerator);
$("#mydiv").html(myDropDown);
}
function getMyitems(listitem)
{
var dropdownOptions = "";
while (listitem.moveNext())
{
var currentValue = listitem.get_current();
dropdownOptions += "<option value='" + currentValue.get_item('myField') + "'>" + currentValue.get_item('myField') + "</option>";
}
return dropdownOptions;
}
</script>
HTML Form Webpart code:
<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
<select id='mydiv' name='myField'>
<option selected='selected'></option>
< /select>
<input type="button" value="Go" onclick="javascript:_SFSUBMIT_"/></div>Please help,

